/* ===================================
   MEETGLE VIDEO CHAT - OPTIMIZED CSS
   =================================== */

/* === CSS VARIABLES === */
:root {
    --accent-color: #cc0000;
    --button-color: #EC4899;
    --button-hover-color: #A855F7;
    --button-active-color: #EC4899;
    --button-padding: 10px 15px;
    --button-font-size: 16px;
    --transition-duration: 0.3s;
    --text-color: #333;
    --bg-dark: #23272A;
    --bg-darker: #171717;
  }
  
  /* === GLOBAL RESET === */
  html,
  body {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  
    /* Avoid 100vw / 100vh issues on iOS */
    width: 100%;
    height: 100%;
    min-height: 0;
  
    overflow-x: hidden;
    overflow-y: auto; /* default for desktop */
  }
  
  /* ===================================
     RESPONSIVE: MOBILE (≤900px)
     =================================== */
  @media (max-width: 900px) {
    /* On mobile, lock the page to the viewport (no scroll) */
    html,
    body {
      overflow: hidden;       /* kill the scroll */
    }
  }
  
  /* === MAIN CONTAINER === */
  #meetgle-container,
  #meetgle-video-container {
    width: 100vw;
    min-height: 100vh;
    min-width: 100vw;
    max-width: 100vw;
    overflow: visible;
    display: flex;
    flex-direction: row;
    box-sizing: border-box;
    text-align: center;
    background-color: transparent;
  }
  
  /* === VIDEO LAYOUT === */
  .video-chat-layout {
    display: flex;
    flex-direction: row;
    width: 100%;
    height: 100%;
  }
  
  .video-section {
    flex: 0 1 50%;
    min-width: 0;
    max-width: 50vw;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    height: 100%;
  }
  
  .controls-and-chat {
    flex: 0 1 50%;
    min-width: 320px;
    max-width: 50vw;
    display: flex;
    flex-direction: column;
    height: 100%;
    box-sizing: border-box;
    background-color: var(--bg-dark);
  }
  
  /* === VIDEO WRAPPERS === */
  .video-wrapper {
    position: relative;
    background-color: #000;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    border-radius: 0;
  }
  
  .video-wrapper.remote-video {
    flex: 1 1 0;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 0;
    margin-bottom: 0;
    background-color: var(--bg-darker);
  }
  
  .video-wrapper.local-video {
    flex: 2 1 0;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 66.66%;
    min-height: 0;
    background-color: #000;
  }
  
  /* === VIDEO ELEMENTS === */
  .remote-video video,
  .local-video video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    position: absolute;
    top: 0;
    left: 0;
    background: url("../img/backgr.png") center center / cover no-repeat;
  }
  
  .local-video video {
    transform: none;
    background-color: #2a2a2a !important;
    background: none;
  }
  
  /* Hide native video controls */
  video::-webkit-media-controls,
  video::-moz-media-controls,
  video::-ms-media-controls,
  video::-o-media-controls {
    display: none !important;
  }
  
  /* === LOADING SPINNER === */
  .remote-loading-spinner {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
  }
  
  .spinner {
    border: 6px solid #f3f3f3;
    border-top: 6px solid var(--button-color);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    animation: spin 1s linear infinite;
  }
  
  @keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
  }
  
  /* === CONTROL BUTTONS === */
  .control-container {
    display: flex;
    justify-content: space-between;
    gap: 5px;
    flex-wrap: wrap;
    margin: 10px;
  }
  
  .control-container button {
    flex: 1;
    padding: 10px;
    font-size: 14px;
    background-color: var(--button-color);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color var(--transition-duration) ease;
    text-align: center;
  }
  
  .control-container button:hover,
  .control-container button:focus {
    background-color: var(--button-hover-color);
  }
  
  .control-container button:active {
    background-color: var(--button-active-color);
  }
  
  #chatActionBtn {
    flex: 8;
  }
  
  #stopChatBtn {
    flex: 2;
  }
  
  /* === MUTE & CAMERA BUTTONS === */
  #muteBtn,
  #switchCameraBtn {
    font-size: 14px;
    color: #000;
    background-color: rgba(255, 255, 255, 0.7);
    border: none;
    padding: 3px 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color var(--transition-duration) ease;
  }
  
  #muteBtn:hover,
  #switchCameraBtn:hover {
    background-color: rgba(200, 200, 200, 0.9);
  }
  
  #muteBtn.muted {
    background-color: #6c757d;
    color: #fff;
  }
  
  /* === HEART & FLAG BUTTONS === */
  #heartBtn,
  #remoteFlag {
    font-size: 18px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.7);
    border: none;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s, box-shadow 0.2s;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
    padding: 0;
    margin: 0 2px;
    cursor: pointer;
  }
  
  #heartBtn:hover,
  #remoteFlag:hover {
    background: rgba(200, 200, 200, 0.9);
  }
  
  #heartBtn:active,
  #remoteFlag:active {
    background: #f3f3f3;
  }
  
  #remoteFlag {
    color: #222;
    cursor: default;
    text-align: center;
    line-height: 36px;
    font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji', sans-serif;
    font-size: 22px;
    overflow: hidden;
    vertical-align: middle;
  }
  
  /* === TEXT CHAT === */
  .text-chat {
    flex: 1 1 0;
    height: 33.33%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    border-radius: 0;
    overflow: hidden;
    background-color: var(--bg-dark);
  }
  
  .messages {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
    background-color: var(--bg-dark);
    color: #fff;
    font-size: 14px;
    line-height: 1.4;
  }
  
  .input-container {
    display: flex;
    padding: 10px;
    background-color: var(--bg-dark);
    border-top: 0;
    margin-bottom: 10px;
  }
  
  #chatInput {
    flex: 1;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    margin-right: 10px;
    font-size: 16px;
  }
  
  #sendMessageBtn {
    padding: 8px 15px;
    background-color: #000;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    margin-left: 10px;
  }
  
  #sendMessageBtn:hover {
    background-color: var(--bg-darker);
  }
  
  /* === STATUS OUTPUT === */
  #statusOutput {
    font-size: 14px;
    color: #fff;
    text-align: center;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 8px 16px;
    border-radius: 4px;
    position: absolute;
    bottom: 50%;
    left: 50%;
    transform: translate(-50%, 50%);
    z-index: 25;
    display: block; /* Controlled by JavaScript */
  }
  
  /* === INTEREST DROPDOWN === */
  .interest-tags-container select {
    width: 100%;
    font-size: 14px;
    color: #333;
    background-color: #f9f9f9;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 5px;
    margin-top: 8px;
    box-sizing: border-box;
    text-align: center;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
  }
  
  /* === HEART ANIMATIONS === */
  .heart-anim-overlay {
    pointer-events: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    overflow: visible;
  }
  
  .heart-emoji {
    position: absolute;
    left: 50%;
    font-size: 2.5rem;
    opacity: 0.85;
    transform: translateX(-50%) scale(1);
    animation: heart-float 1.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    pointer-events: none;
  }
  
  @keyframes heart-float {
    0% {
      top: 10%;
      opacity: 0.9;
      transform: translateX(-50%) scale(1.2);
    }
    60% {
      opacity: 1;
      transform: translateX(-50%) scale(1.1) rotate(-10deg);
    }
    80% {
      opacity: 0.8;
      transform: translateX(-50%) scale(1.05) rotate(10deg);
    }
    100% {
      top: 80%;
      opacity: 0;
      transform: translateX(-50%) scale(0.8) rotate(0deg);
    }
  }
  
  .heart-btn-anim-overlay {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
    z-index: 200;
  }
  
  .heart-btn-emoji {
    position: absolute;
    left: 50%;
    bottom: 8px;
    font-size: 1.7em;
    opacity: 0.9;
    transform: translateX(-50%) scale(1);
    animation: heart-btn-flutter 0.9s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    pointer-events: none;
  }
  
  @keyframes heart-btn-flutter {
    0% {
      bottom: 8px;
      opacity: 0.9;
      transform: translateX(-50%) scale(1.2);
    }
    60% {
      opacity: 1;
      transform: translateX(-50%) scale(1.1) rotate(-10deg);
    }
    80% {
      opacity: 0.8;
      transform: translateX(-50%) scale(1.05) rotate(10deg);
    }
    100% {
      bottom: 38px;
      opacity: 0;
      transform: translateX(-50%) scale(0.8) rotate(0deg);
    }
  }
  
  /* ===================================
     RESPONSIVE: DESKTOP (900px+)
     =================================== */
  @media (min-width: 901px) {
    #meetgle-video-container,
    .video-chat-layout {
      height: 100vh;
      min-height: 100vh;
      max-height: 100vh;
    }
  }
  
  /* ===================================
     RESPONSIVE: MOBILE (≤900px)
     =================================== */
     @media (max-width: 900px) {
      .video-chat-layout {
        flex-direction: column;
        height: 100vh !important;
        min-height: 100vh !important;
        max-height: 100vh !important;
      }
    
      .video-section,
      .controls-and-chat {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100vw !important;
        flex: unset !important;
        padding: 0 !important;
      }
    
      /* === EQUAL HEIGHT VIDEO WRAPPERS ON MOBILE (FALLBACK USING VH) === */
      .video-section {
        height: 50vh !important;
        min-height: 50vh !important;
        max-height: 50vh !important;
        margin: 0 !important;
        padding: 0 !important;
        display: block !important;
      }
    
      .controls-and-chat {
        height: 50vh !important;
        min-height: 50vh !important;
        max-height: 50vh !important;
        display: block !important;
      }
    
      .video-wrapper.remote-video,
      .video-wrapper.local-video {
        height: 50vh !important;
        min-height: 0 !important;
        max-height: 50vh !important;
        aspect-ratio: unset !important;
        flex: unset !important;
        margin: 0 !important;
        padding: 0 !important;
      }
    
      /* === MODERN FIX FOR iOS / MOBILE BROWSERS USING SVH === */
      @supports (height: 100svh) {
        .video-chat-layout {
          height: 100svh !important;
          min-height: 100svh !important;
          max-height: 100svh !important;
        }
    
        .video-section,
        .controls-and-chat {
          height: 50svh !important;
          min-height: 50svh !important;
          max-height: 50svh !important;
        }
    
        .video-wrapper.remote-video,
        .video-wrapper.local-video {
          height: 50svh !important;
          min-height: 0 !important;
          max-height: 50svh !important;
        }
      }
    
      .video-wrapper::before {
        display: none !important;
      }
    
      .remote-video video,
      .local-video video {
        width: 100% !important;
        height: 100% !important;
        min-height: 0 !important;
        max-height: 100% !important;
      }
    }  
  
    #heartBtn,
    #remoteFlag {
      font-size: 14px;
      width: 28px;
      height: 28px;
    }
  
    #remoteFlag {
      font-size: 16px;
      line-height: 28px;
    }
    
    /* Extra button font size on mobile */
    .meetgle-extra-btn {
      font-size: 14px !important;
    }
    
    /* Next button font size on mobile */
    #nextChatBtn {
      font-size: 14px !important;
    }
    
    /* Start button font size on mobile */
    #startChatBtn {
      font-size: 14px !important;
    }
  
  /* ===================================
     RESPONSIVE: SMALL MOBILE (≤600px)
     =================================== */
  @media (max-width: 600px) {
    .control-container {
      margin: 5px;
    }
  }