/* ============================================
   RESPONSIVE.CSS - Arquivo de Responsividade
   ============================================ */

/* ============================================
   MENU HAMBURGER - Estilos base
   ============================================ */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 30px;
  height: 24px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: 1001;
  transition: transform 0.3s ease;
}

.hamburger span {
  display: block;
  width: 100%;
  height: 3px;
  background-color: var(--primary);
  border-radius: 3px;
  transition: all 0.3s ease;
}

.hamburger:hover {
  transform: scale(1.05);
}

/* Animação do hamburger quando ativo */
.hamburger.active span:nth-child(1) {
  transform: translateY(10.5px) rotate(45deg);
}

.hamburger.active span:nth-child(2) {
  opacity: 0;
  transform: translateX(-20px);
}

.hamburger.active span:nth-child(3) {
  transform: translateY(-10.5px) rotate(-45deg);
}

/* Overlay quando menu está aberto */
body.menu-open::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Tablets e dispositivos médios (768px ou menos) */
@media (max-width: 768px) {
  /* Ajustar header */
  header {
    position: sticky;
  }

  nav {
    flex-wrap: wrap;
    gap: 1rem;
  }

  /* Logo menor em mobile */
  .logo {
    width: 150px;
  }

  /* Mostrar botão hamburger */
  .hamburger {
    display: flex;
    order: 3;
  }

  /* Brand e User lado a lado */
  .brand {
    order: 1;
    flex: 0 0 auto;
  }

  .user {
    order: 2;
    flex: 1;
    justify-content: flex-end;
  }

  .btn-logout {
    order: 4;
    width: 100%;
    justify-content: center;
    margin-top: 0.5rem;
  }

  /* Navegação - Index.html (#nav) */
  .nav {
    position: fixed;
    top: 100%;
    right: -100%;
    width: 280px;
    height: 40vh;
    background: white;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    padding: 80px 20px 20px;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    flex-direction: column;
    gap: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .nav.active {
    right: 0;
  }

  .nav a {
    width: 100%;
    padding: 15px 20px;
    border-radius: 8px;
    border: none;
    margin-bottom: 5px;
    font-size: 16px;
    text-align: left;
    transition: all 0.3s ease;
  }

  .nav a:hover,
  .nav a:active {
    background: var(--primary);
    color: white;
    transform: translateX(5px);
  }

  .nav a.active {
    background: var(--primary);
    color: white;
  }

  /* Navegação - Programacao.html (.nav-links) */
  .nav-links {
    position: fixed;
    top: 147px;
    right: -100%;
    width: 280px;
    height: 100vh;
    background: white;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    padding: 80px 20px 20px;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    flex-direction: column;
    gap: 0;
    list-style: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .nav-links.active {
    right: 0;
  }

  .nav-links li {
    width: 100%;
    margin-bottom: 5px;
  }

  .nav-links a {
    display: block;
    width: 100%;
    padding: 15px 20px;
    border-radius: 8px;
    font-size: 16px;
    text-align: left;
    transition: all 0.3s ease;
  }

  .nav-links a:hover,
  .nav-links a:active {
    background: var(--primary);
    color: white;
    transform: translateX(5px);
  }

  .nav-links a.active {
    background: var(--primary);
    color: white;
  }

  /* Containers e Grid */
  .programming-container {
    grid-template-columns: 1fr;
  }

  .grid.cols-2 {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .filter-grid {
    grid-template-columns: 1fr;
  }

  /* Welcome container */
  .welcome-container {
    padding: 2rem 1rem;
  }

  .welcome-container h1 {
    font-size: 2rem;
  }

  /* Features */
  .features {
    grid-template-columns: 1fr;
  }

  /* Análise */
  .analysis-controls {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .stats-container {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    padding: 12px;
  }

  .stat-box {
    padding: 12px 8px;
  }

  .stat-box strong {
    font-size: 24px;
  }

  .analysis-section {
    padding: 16px;
    margin-top: 20px;
  }

  /* Modal */
  .modal-content {
    width: 95%;
    padding: 1.5rem;
    max-height: 90vh;
  }

  dialog {
    width: 95vw;
  }

  /* Topbar */
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .brand {
    justify-content: center;
  }

  .user {
    justify-content: center;
  }

  /* Toolbar */
  .toolbar {
    flex-direction: column;
  }

  .toolbar .btn {
    width: 100%;
    justify-content: center;
  }
}

/* Tabelas responsivas (720px ou menos) */
@media (max-width: 720px) {
  /* Ajuste geral de containers */
  .container {
    padding: 0 10px;
  }

  main {
    padding: 1rem 0;
  }

  /* Tabelas em modo card */
  table {
    border: 0;
  }

  table thead {
    display: none;
  }

  table, tbody, tr, td {
    display: block;
    width: 100%;
  }

  tr {
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 15px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    overflow: hidden;
  }

  td {
    border-bottom: 1px dashed var(--border);
    padding: 12px 15px;
    position: relative;
    text-align: right;
    padding-left: 50%;
  }

  td:last-child {
    border-bottom: none;
  }

  td::before {
    content: attr(data-label);
    position: absolute;
    left: 15px;
    width: 45%;
    padding-right: 10px;
    white-space: nowrap;
    text-align: left;
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 600;
  }

  /* Ajustes para itens de repertório */
  .repertorio-details {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .repertorio-details > div {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px dashed var(--border);
  }

  .repertorio-details > div:last-child {
    border-bottom: none;
  }

  /* Divisores */
  .divisor-order {
    top: 0.5rem;
    right: 0.5rem;
    width: 22px;
    height: 22px;
    font-size: 0.75rem;
  }

  .divisor-header {
    flex-wrap: wrap;
  }

  /* Ações em cards */
  .card-actions,
  .repertorio-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
  }

  .card-actions .btn,
  .repertorio-actions .btn {
    flex: 1;
    min-width: calc(50% - 0.25rem);
  }
}

/* Smartphones pequenos (480px ou menos) */
@media (max-width: 480px) {
  /* Typography */
  .welcome-container h1 {
    font-size: 1.5rem;
    line-height: 1.3;
  }

  .welcome-container p {
    font-size: 0.95rem;
    line-height: 1.5;
  }

  /* Buttons */
  .btn {
    padding: 0.7rem 1rem;
    font-size: 0.9rem;
    width: 100%;
    justify-content: center;
  }

  /* Ajustar botões em linha para ficarem empilhados */
  div[style*="display: flex"] .btn {
    width: 100%;
  }

  /* Cards */
  .card,
  .programming-section {
    padding: 1rem;
  }

  .card .head {
    padding: 10px 12px;
  }

  .programming-section h3 {
    font-size: 1rem;
  }

  /* Modal */
  .modal-content {
    padding: 1rem;
    width: 95%;
    border-radius: 15px;
  }

  .modal-header h2 {
    font-size: 1.2rem;
  }

  .close-btn {
    font-size: 1.8rem;
    padding: 0.5rem;
  }

  /* Stats */
  .stats-container {
    grid-template-columns: 1fr;
  }

  .stat-box strong {
    font-size: 20px;
  }

  /* Logo */
  .logo {
    width: 120px;
  }

  /* Form inputs - tamanho mínimo para evitar zoom no iOS */
  .input, 
  .form-group input,
  .form-group select, 
  .form-group textarea {
    font-size: 16px !important;
  }

  /* Repertório items */
  .repertorio-item {
    padding: 0.75rem;
  }

  .repertorio-item h4 {
    font-size: 0.95rem;
  }

  .repertorio-details {
    font-size: 0.85rem;
    gap: 0.75rem;
  }

  .divisor-item {
    padding: 0.75rem;
  }

  .divisor-title {
    font-size: 0.95rem;
  }

  /* Row */
  .row {
    flex-direction: column;
    align-items: stretch;
  }

  /* Filter section */
  .filter-section {
    padding: 1rem;
  }

  /* Features */
  .feature {
    padding: 1.5rem;
  }

  .feature h3 {
    font-size: 1.1rem;
  }

  .feature i {
    font-size: 2rem;
  }
}

/* Dispositivos muito pequenos (360px ou menos) */
@media (max-width: 360px) {
  body {
    font-size: 14px;
  }

  nav {
    padding: 0.75rem 0;
  }

  .welcome-container {
    padding: 1.5rem 1rem;
  }

  .welcome-container h1 {
    font-size: 1.3rem;
  }

  .btn {
    padding: 0.6rem 0.8rem;
    font-size: 0.85rem;
  }

  .logo {
    width: 100px;
  }

  .stat-box strong {
    font-size: 18px;
  }

  .modal-content {
    width: 98%;
    padding: 0.75rem;
  }

  .form-group label {
    font-size: 0.9rem;
  }

  .programming-section {
    padding: 0.75rem;
  }

  .repertorio-item,
  .divisor-item {
    padding: 0.5rem;
  }

  /* Ajustar navegação mobile para telas muito pequenas */
  .nav,
  .nav-links {
    width: 100%;
    right: -100%;
  }

  .nav.active,
  .nav-links.active {
    right: 0;
  }
}

/* Landscape em dispositivos móveis */
@media (max-height: 500px) and (orientation: landscape) {
  .modal-content {
    max-height: 95vh;
    overflow-y: auto;
  }

  .welcome-container {
    padding: 1.5rem;
  }

  header {
    position: static;
  }

  .nav,
  .nav-links {
    padding-top: 60px;
  }

  .programming-container {
    gap: 1rem;
  }
}

/* Tablets em modo landscape (1024px ou menos) */
@media (max-width: 1024px) and (min-width: 769px) {
  .container {
    padding: 0 20px;
  }

  main {
    padding: 1.5rem 0;
  }

  .programming-container {
    gap: 1.5rem;
  }

  .form-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .features {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Print styles */
@media print {
  header,
  footer,
  .btn,
  .toolbar,
  .nav,
  .nav-links,
  .hamburger,
  .filter-section {
    display: none;
  }

  body {
    background: white;
  }

  .card,
  .programming-section {
    box-shadow: none;
    border: 1px solid #ddd;
    page-break-inside: avoid;
  }

  table {
    page-break-inside: auto;
  }

  tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }
}

/* Dark mode support (opcional) */
@media (prefers-color-scheme: dark) {
  /* Descomente se quiser suporte a dark mode automático */
  /*
  :root {
    --bg: #1a1a1a;
    --surface: #2a2a2a;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --border: #374151;
  }
  */
}

/* Reduced motion para acessibilidade */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
/* Ajuste: reduzir espaçamento dos itens do menu hamburger (mobile) */
@media (max-width: 768px) {
  /* Menus .nav e .nav-links — espaçamento compacto */
  .nav, .nav-links {
    width: 220px;
    padding: 30px;
  }

  /* Itens do menu: menos gap e padding reduzido */
  .nav > a,
  .nav li,
  .nav-links li,
  .nav-links a {
    margin: 0 0 6px 0;      /* distância entre itens (menor) */
    padding: 8px 10px;      /* padding interno reduzido */
    font-size: 15px;
  }

  .nav-links li a {
    padding: 8px 10px;
  }

  /* Em caso de hover/ativo, manter contraste mas sem deslocamento */
  .nav a:hover,
  .nav-links a:hover,
  .nav a.active,
  .nav-links a.active {
    background: var(--primary);
    color: #fff;
    transform: none;
  }
}
