/* ============================================
   RESPONSIVE STYLES - Centralized Media Queries
   ============================================ */

/* ====== MOBILE SMALL (max-width: 480px) ====== */
@media (max-width: 480px) {
  /* Session Info - Tutor Controls */
  #sessionInfo .tutor-controls button {
    flex: 1 1 45%;
    min-width: 140px;
  }
  
  #tutorPlayback .actions button {
    flex: 1 1 45%;
    min-width: 140px;
  }
  
  #tutorPlayback .progress-row {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  
  /* Time Credits Modal */
  #timeCreditsModal {
    align-items: flex-start;
    justify-content: flex-start;
  }
  
  /* Participant Input */
  .participant-input {
    gap: 8px;
  }
  
  .participant-input button {
    min-width: 120px;
    height: 42px;
  }
}

/* ====== MOBILE (max-width: 520px) ====== */
@media (max-width: 520px) {
  /* Tutor - Participant List */
  #page-tutor #participantsList .pi-item {
    gap: 8px;
    flex-wrap: nowrap;
    align-items: center;
  }
  
  #page-tutor #participantsList .pi-name {
    flex: 1 1 auto;
    min-width: 80px;
    font-size: 13px;
  }
  
  #page-tutor #participantsList .pi-ok,
  #page-tutor #participantsList .pi-inc {
    padding: 4px 8px;
    font-size: 12px;
    line-height: 1;
  }
  
  /* Session Header - Stack vertically */
  #page-tutor .session-header-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  
  #page-tutor .session-header-row > p {
    margin: 0;
  }
  
  #btnShowQR {
    width: 100%;
  }
  
  /* QR Modal */
  #qrModal {
    padding: 12px;
  }
  
  #qrModal .modal-content {
    width: calc(100% - 24px);
    max-width: 100%;
    margin: 0;
  }
  
  #qrModal .modal-body {
    padding: 20px 18px !important;
    gap: 14px !important;
  }
  
  #qrModal #qrCodeContainer {
    width: 220px !important;
    min-height: 220px !important;
  }
  
  #qrModal #qrCodeContainer canvas {
    width: 220px !important;
    height: 220px !important;
  }
  
  #qrModal #qrSessionIdRow {
    max-width: 100%;
    font-size: 12px;
    padding: 8px 10px;
  }
  
  /* Tutor Controls - Grid 2x2 */
  #sessionInfo > .tutor-controls:not(#tutorPlayback) {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }
  
  #sessionInfo > .tutor-controls:not(#tutorPlayback) button {
    width: 100% !important;
    min-width: 0 !important;
    flex: none !important;
  }
  
  /* Progress Bar */
  .avance-row {
    gap: 8px;
    margin: 12px 0 16px;
  }
  
  .progress {
    height: 10px;
  }
  
  .progress-text {
    font-size: 13px;
    min-width: 48px;
  }
  
  /* Peer Banner */
  .peer-banner {
    flex-direction: column;
    gap: 8px;
    padding: 12px;
  }
  
  .peer-banner__icon {
    font-size: 20px;
  }
  
  .peer-banner__title {
    font-size: 16px;
  }
  
  /* Participant Report - Botones horizontales */
  #participantReport .actions {
    display: flex !important;
    flex-direction: row !important;
    gap: 6px !important;
    align-items: stretch !important;
    justify-content: center !important;
  }
  
  #participantReport .actions button {
    flex: 1 1 calc(50% - 3px) !important;
    min-width: 0 !important;
    white-space: normal !important;
    padding: 10px 6px !important;
    font-size: 13px !important;
    line-height: 1.3 !important;
    text-align: center !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  
  /* Final Congrats Card */
  .final-congrats-card {
    padding: 20px 16px;
    width: calc(100% - 24px);
  }
  
  /* Badges */
  .badge {
    font-size: 11px;
    padding: 2px 6px;
  }
}

/* ====== TABLET (max-width: 640px) ====== */
@media (max-width: 640px) {
  /* Report Summary responsive rules moved to components/reportes.css */
}

/* ====== TABLET/MOBILE (max-width: 768px) ====== */
@media (max-width: 768px) {
  /* Global Container */
  .container {
    padding: 20px 14px 40px;
  }
  
  h2 {
    font-size: 24px;
  }
  
  .card {
    padding: 16px;
    margin-left: 12px;
    margin-right: 12px;
  }
  
  /* Forms */
  input[type="text"],
  input[type="number"],
  select,
  .row input[type="text"],
  .row button {
    width: 100% !important;
    flex: none !important;
  }
  
  /* Virtual Keyboard */
  #virtual-keyboard-container {
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }
  
  .virtual-keyboard-theme .hg-button {
    font-size: 20px;
    padding: 14px 12px;
  }
  
  /* Tutorial */
  .tutorial-tooltip {
    max-width: calc(100vw - 40px);
    padding: 20px;
  }
  
  /* Tutor Controls */
  .tutor-controls {
    flex-direction: column;
  }
  
  #tutorPlayback .actions button {
    min-width: calc(50% - 8px);
    flex: 1 1 auto;
  }
  
  /* Participant Input */
  .participant-input {
    flex-direction: column;
    align-items: stretch;
  }
  
  .participant-input input {
    width: 100%;
    margin-bottom: 8px;
  }
  
  .racha-notification {
    top: 60px;
    font-size: 15px;
    padding: 10px 16px;
  }
  
  /* Help Button */
  .help-button {
    top: 10px;
    right: 10px;
  }
  
  /* Config Card */
  .config-card {
    padding: 20px;
  }
  
  .config-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  
  .config-row .config-label {
    min-width: 0;
  }
  
  /* Layout Game Input - Botones horizontales */
  .row.layout-game-input {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    align-items: stretch !important;
    gap: 10px !important;
  }
  
  /* Input/mirror en primera fila, 100% ancho */
  .row.layout-game-input #respuesta {
    order: 1 !important;
    width: 100% !important;
    flex: 1 1 100% !important;
    box-sizing: border-box !important;
  }
  
  .row.layout-game-input #vkMirror {
    order: 1 !important;
    width: 100% !important;
    flex: 1 1 100% !important;
    box-sizing: border-box !important;
  }
  
  /* Botones en segunda fila, 50% cada uno */
  .row.layout-game-input #btnSpeak {
    order: 2 !important;
    flex: 0 0 calc(50% - 5px) !important;
    min-width: 0 !important;
    width: calc(50% - 5px) !important;
    max-width: calc(50% - 5px) !important;
    box-sizing: border-box !important;
  }
  
  .row.layout-game-input #btnComprobar {
    order: 3 !important;
    flex: 0 0 calc(50% - 5px) !important;
    min-width: 0 !important;
    width: calc(50% - 5px) !important;
    max-width: calc(50% - 5px) !important;
    box-sizing: border-box !important;
  }
  
  /* Botón de permiso de audio en tercera fila */
  .row.layout-game-input #btnEnableAudio {
    order: 4 !important;
    width: 100% !important;
    flex: 1 1 100% !important;
    box-sizing: border-box !important;
  }
  
  /* Botones con altura duplicada para mejor táctil */
  .row.layout-game-input button {
    padding: 20px 10px !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    line-height: 1.4 !important;
  }
  
  /* Ajuste adicional para móviles pequeños dentro de 768px */
  @media (max-width: 520px) {
    .row.layout-game-input {
      gap: 8px !important;
    }
    
    .row.layout-game-input button {
      padding: 18px 8px !important;
      font-size: 14px !important;
      font-weight: 600 !important;
    }
    
    .row.layout-game-input #btnSpeak,
    .row.layout-game-input #btnComprobar {
      flex: 0 0 calc(50% - 4px) !important;
      width: calc(50% - 4px) !important;
      max-width: calc(50% - 4px) !important;
    }
  }
}

/* ====== TABLET LANDSCAPE (min-width: 769px and max-width: 1023px) ====== */
@media (min-width: 769px) and (max-width: 1023px) {
  .virtual-keyboard-theme .hg-button {
    font-size: 19px;
    padding: 12px 12px;
  }
}

/* ====== DESKTOP (min-width: 1024px) ====== */
@media (min-width: 1024px) {
  /* Hide VK Mirror on desktop */
  #vkMirror,
  #vkMirrorParticipant {
    display: none !important;
  }
}

/* ====== MOBILE VK SPECIFIC (max-width: 1023px) ====== */
@media (max-width: 1023px) {
  /* Hide real inputs, show mirror */
  #page-game #respuesta {
    display: none !important;
  }
  
  #page-game #vkMirror {
    display: block !important;
  }
  
  #page-participant #participantAnswer {
    display: none !important;
  }
  
  #page-participant #vkMirrorParticipant {
    display: block !important;
  }
}
