/* ---------- base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}
.app-wrapper {
  width: 100%;
  min-height: 100%;
}

/* ---------- calendário ---------- */
.dia-calendario {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
  min-height: 2.5rem;
  font-size: 0.875rem;
}
.dia-livre {
  background: #f3f4f6 !important;
  color: #374151 !important;
}
.dia-livre:hover {
  background: #e5e7eb !important;
}
.dia-reservado {
  background: #ef4444 !important;
  color: #fff !important;
  cursor: default;
}
.dia-outro-mes {
  opacity: 0.3;
}
.dia-hoje {
  border: 2px solid #7c3aed !important;
  font-weight: 700;
}

/* ---------- formulário / lista ---------- */
input, select, button {
  font-family: inherit;
}
#reserva-form button[type="submit"],
#btn-mes-anterior,
#btn-mes-proximo {
  background-color: #7c3aed !important;
  border: none !important;
  color: #fff !important;
}
#reserva-form button[type="submit"]:hover,
#btn-mes-anterior:hover,
#btn-mes-proximo:hover {
  background-color: #6d28d9 !important;
}

/* ---------- botão Editar AZUL (sempre visível) ---------- */
.app-wrapper .edit-btn,
.app-wrapper button.edit-btn {
  background-color: #2563eb !important;
  border: none !important;
  color: #fff !important;
  padding: 0.25rem 0.75rem !important;
  font-size: 0.75rem !important;
  border-radius: 0.25rem !important;
  cursor: pointer !important;
  transition: background-color 0.2s ease !important;
}

.app-wrapper .edit-btn:hover,
.app-wrapper button.edit-btn:hover {
  background-color: #1d4ed8 !important;
}

/* ---------- utilitários ---------- */
.text-center { text-align: center; }
.text-gray-500 { color: #6b7280; }
.text-gray-600 { color: #4b5563; }
.text-gray-700 { color: #374151; }
.text-gray-800 { color: #1f2937; }
.text-purple-100 { color: #e9d5ff; }
.text-white { color: #fff; }
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-2xl { font-size: 1.5rem; }
.text-4xl { font-size: 2.25rem; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }
.bg-white { background-color: #fff !important; }
.bg-gray-200 { background-color: #e5e7eb !important; }
.bg-red-500 { background-color: #ef4444 !important; }
.bg-purple-600 { background-color: #7c3aed !important; }
.border { border-width: 1px; }
.border-gray-200 { border-color: #e5e7eb !important; }
.border-gray-300 { border-color: #d1d5db !important; }
.rounded-lg { border-radius: 0.5rem; }
.rounded-xl { border-radius: 0.75rem; }
.shadow-xl { box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04); }
.p-3 { padding: 0.75rem; }
.p-6 { padding: 1.5rem; }
.py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-8 { margin-bottom: 2rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-4 { margin-top: 1rem; }
.space-y-3 > * + * { margin-top: 0.75rem; }
.space-y-4 > * + * { margin-top: 1rem; }
.space-y-6 > * + * { margin-top: 1.5rem; }
.grid { display: grid; }
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-7 { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1 1 0%; }
.max-h-96 { max-height: 24rem; }
.overflow-y-auto { overflow-y: auto; }
.hidden { display: none; }
.w-4 { width: 1rem; }
.h-4 { height: 1rem; }
.w-full { width: 100%; }
.transition-colors { transition-property: background-color, border-color, color, fill, stroke; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 150ms; }
.hover\:bg-gray-400:hover { background-color: #9ca3af !important; }
.hover\:bg-red-600:hover { background-color: #dc2626 !important; }
.hover\:bg-blue-600:hover { background-color: #1d4ed8 !important; }
.hover\:shadow-md:hover { box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06) !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-purple-600 { color: #7c3aed !important; }
.lg\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* ---------- botão de impressão ---------- */
#btn-imprimir {
  background-color: #10b981 !important;
  border: none !important;
  color: #fff !important;
  padding: 0.5rem 1rem !important;
  font-size: 0.875rem !important;
  border-radius: 0.5rem !important;
  cursor: pointer !important;
  transition: background-color 0.2s ease !important;
  white-space: nowrap;
}

#btn-imprimir:hover {
  background-color: #059669 !important;
}

/* ---------- filtro de mês ---------- */
#filtro-mes {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  color: #374151;
}

#filtro-mes:focus {
  outline: none;
  ring: 2px;
  ring-color: #7c3aed;
  border-color: transparent;
}

/* ---------- modal de impressão ---------- */
#modal-impressao {
  display: none;
}

#modal-impressao button {
  font-family: inherit;
}

/* ========== RESPONSIVIDADE ========== */

/* ---------- responsividade do filtro e impressão ---------- */
@media (max-width: 640px) {
  .flex.items-center.justify-between.mb-4 {
    flex-direction: column;
    gap: 0.75rem;
  }
  
  #btn-imprimir {
    width: 100%;
  }
  
  .grid.grid-cols-2.gap-3.mb-4 {
    grid-template-columns: 1fr !important;
  }
}

/* MOBILE FIRST - Até 640px */
@media (max-width: 640px) {
  .app-wrapper {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  }
  
  .w-full.min-h-full.px-6.py-8 {
    padding: 0.75rem;
  }
  
  .max-w-7xl.mx-auto {
    max-width: 100%;
    padding: 0;
  }
  
  /* Títulos menores em mobile */
  #titulo-pagina {
    font-size: 1.5rem !important;
    margin-bottom: 0.5rem !important;
  }
  
  .text-4xl {
    font-size: 1.5rem;
  }
  
  .text-2xl {
    font-size: 1.125rem;
  }
  
  /* Grid de 1 coluna em mobile */
  .grid-cols-1.lg\:grid-cols-2 {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  
  /* Reduz padding em cards */
  .p-6 {
    padding: 0.75rem;
  }
  
  .px-6 {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
  
  /* Botões de navegação do calendário */
  #btn-mes-anterior,
  #btn-mes-proximo {
    padding: 0.4rem 0.6rem !important;
    font-size: 0.7rem !important;
    flex: 1;
  }
  
  .flex.items-center.justify-between.mb-4 {
    display: flex;
    gap: 0.5rem;
  }
  
  #mes-ano {
    font-size: 0.95rem;
    white-space: nowrap;
  }
  
  /* CALENDÁRIO - Melhorado para mobile */
  #dias-calendario {
    grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
    gap: 0.25rem !important;
  }
  
  .dia-calendario {
    min-height: 2rem;
    font-size: 0.7rem;
    padding: 0.25rem;
    border-radius: 0.25rem;
  }
  
  /* Cabeçalho do calendário */
  .grid.grid-cols-7.gap-2.mb-2 {
    gap: 0.25rem !important;
    font-size: 0.65rem !important;
  }
  
  .grid.grid-cols-7.gap-2.mb-2 div {
    font-size: 0.65rem;
    font-weight: 600;
  }
  
  /* Legenda do calendário */
  .mt-4.flex.gap-4.text-sm {
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.7rem;
  }
  
  .mt-4.flex.gap-4.text-sm div {
    font-size: 0.7rem;
  }
  
  /* Formulário em mobile */
  .grid-cols-2 {
    grid-template-columns: 1fr;
  }
  
  /* Botões do formulário em mobile */
  .flex.gap-2.mt-4 {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  #btn-adicionar,
  #btn-cancelar {
    width: 100%;
    padding: 0.75rem !important;
    font-size: 0.9rem !important;
  }
  
  /* Lista de reservas mais compacta */
  #reservas-container {
    max-height: 40vh;
  }
  
  .border.border-gray-200.rounded-lg.p-3 {
    padding: 0.5rem;
  }
  
  .flex.justify-between.items-start {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .flex.gap-2 {
    width: 100%;
    gap: 0.25rem;
  }
  
  .flex.gap-2 button {
    flex: 1;
    font-size: 0.65rem !important;
    padding: 0.4rem !important;
  }
  
  /* Reduz espaçamento geral */
  .mb-8 {
    margin-bottom: 0.75rem;
  }
  
  .space-y-6 > * + * {
    margin-top: 0.75rem;
  }
  
  .space-y-4 > * + * {
    margin-top: 0.5rem;
  }
  
  /* Inputs e labels */
  input, select {
    font-size: 1rem;
    padding: 0.6rem;
  }
  
  label {
    font-size: 0.8rem;
  }
  
  .mb-1 {
    margin-bottom: 0.15rem;
  }
}

/* TABLET - 641px até 1024px */
@media (min-width: 641px) and (max-width: 1024px) {
  .app-wrapper {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  }
  
  .w-full.min-h-full.px-6.py-8 {
    padding: 1.25rem;
  }
  
  .max-w-7xl.mx-auto {
    max-width: 100%;
  }
  
  #titulo-pagina {
    font-size: 1.75rem !important;
  }
  
  .text-4xl {
    font-size: 1.75rem;
  }
  
  .text-2xl {
    font-size: 1.25rem;
  }
  
  /* Grid de 2 colunas em tablet */
  .grid-cols-1.lg\:grid-cols-2 {
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }
  
  .p-6 {
    padding: 1rem;
  }
  
  .px-6 {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  
  /* Calendário em tablet */
  #dias-calendario {
    grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
    gap: 0.4rem !important;
  }
  
  .dia-calendario {
    min-height: 2.25rem;
    font-size: 0.8rem;
  }
  
  #btn-mes-anterior,
  #btn-mes-proximo {
    padding: 0.5rem 0.8rem !important;
    font-size: 0.8rem !important;
  }
}

/* DESKTOP - Acima de 1024px */
@media (min-width: 1025px) {
  .app-wrapper {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  }
  
  .w-full.min-h-full.px-6.py-8 {
    padding: 2rem;
  }
  
  .max-w-7xl.mx-auto {
    max-width: 80rem;
  }
  
  #titulo-pagina {
    font-size: 2.25rem !important;
  }
  
  .text-4xl {
    font-size: 2.25rem;
  }
  
  .text-2xl {
    font-size: 1.5rem;
  }
  
  /* Grid de 2 colunas em desktop */
  .grid-cols-1.lg\:grid-cols-2 {
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
  }
  
  .p-6 {
    padding: 1.5rem;
  }
  
  .px-6 {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
  
  /* Calendário em desktop */
  #dias-calendario {
    grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
    gap: 0.5rem !important;
  }
  
  .dia-calendario {
    min-height: 2.5rem;
    font-size: 0.875rem;
  }
  
  #btn-mes-anterior,
  #btn-mes-proximo {
    padding: 0.5rem 1rem !important;
    font-size: 1rem !important;
  }
}

/* Ajustes para telas muito pequenas (< 375px) */
@media (max-width: 374px) {
  .app-wrapper {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  }
  
  .w-full.min-h-full.px-6.py-8 {
    padding: 0.5rem;
  }
  
  #titulo-pagina {
    font-size: 1.25rem !important;
  }
  
  .text-2xl {
    font-size: 1rem;
  }
  
  .p-6 {
    padding: 0.5rem;
  }
  
  .px-6 {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
  
  .dia-calendario {
    font-size: 0.6rem;
    min-height: 1.75rem;
  }
  
  .flex.gap-2 button {
    font-size: 0.6rem;
    padding: 0.3rem !important;
  }
  
  #btn-mes-anterior,
  #btn-mes-proximo {
    padding: 0.3rem 0.5rem !important;
    font-size: 0.6rem !important;
  }
}

/* Suporte para orientação landscape em mobile */
@media (max-height: 500px) and (orientation: landscape) {
  .app-wrapper {
    min-height: auto;
  }
  
  .w-full.min-h-full.px-6.py-8 {
    padding: 0.5rem;
  }
  
  #titulo-pagina {
    font-size: 1.1rem !important;
    margin-bottom: 0.25rem !important;
  }
  
  .mb-8 {
    margin-bottom: 0.25rem;
  }
  
  .p-6 {
    padding: 0.5rem;
  }
  
  .grid-cols-1.lg\:grid-cols-2 {
    gap: 0.5rem;
  }
  
  #reservas-container {
    max-height: 20vh;
  }
  
  .space-y-6 > * + * {
    margin-top: 0.5rem;
  }
}
