/**
 * ==============================================================================
 * Cardápio Fácil — Estilos do Painel Administrativo, Autenticação e Impressão A6
 * ==============================================================================
 */

/* ------------------------------------------------------------------------------
 * 1. PÁGINA DE AUTENTICAÇÃO (entrar.html)
 * ------------------------------------------------------------------------------ */
.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(800px 500px at 50% -10%, rgba(185, 234, 203, 0.45), transparent 70%),
    var(--green-50);
}

.auth-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
}

.auth-card {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px 28px;
}

.auth-tabs {
  display: flex;
  background: var(--green-50);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 24px;
  gap: 4px;
}

.auth-tab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 10px 14px;
  border-radius: 999px;
  transition: all 0.2s ease;
  text-align: center;
}

.auth-tab.is-active {
  background: var(--white);
  color: var(--green-800);
  box-shadow: var(--shadow-sm);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.auth-view-header {
  margin-bottom: 20px;
  text-align: center;
}

.auth-view-header h3 {
  font-size: 1.3rem;
  margin-bottom: 6px;
}

.auth-view-header p {
  color: var(--muted);
  font-size: 0.92rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.link-btn {
  background: none;
  border: none;
  color: var(--green-700);
  font-size: 0.84rem;
  font-weight: 600;
  padding: 0;
  text-decoration: underline;
  cursor: pointer;
}

.link-btn:hover {
  color: var(--green-800);
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="tel"],
.field input[type="date"],
.select-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--white);
  font-size: 0.95rem;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus,
.select-input:focus {
  border-color: var(--green-600);
  box-shadow: 0 0 0 3px rgba(34, 160, 90, 0.18);
  outline: none;
}

.field-hint {
  font-size: 0.78rem;
  color: var(--muted);
}

.btn-block {
  width: 100%;
}

.btn-small {
  padding: 8px 16px;
  font-size: 0.85rem;
}

/* ------------------------------------------------------------------------------
 * 2. ALERTAS E BANNERS
 * ------------------------------------------------------------------------------ */
.alert-box {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 20px;
  line-height: 1.45;
}

.alert-error {
  background: #fef3f2;
  border: 1px solid #fee4e2;
  color: var(--red-700);
}

.alert-success {
  background: #ecfdf3;
  border: 1px solid #d1fadf;
  color: #027a48;
}

.alert-warning {
  background: #fffaeb;
  border: 1px solid #fedf89;
  color: #b54708;
}

.convite-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--green-100);
  border: 1px solid var(--green-200);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 20px;
}

.convite-icon {
  font-size: 1.6rem;
}

.convite-banner strong {
  display: block;
  font-size: 0.92rem;
  color: var(--green-800);
}

.convite-banner p {
  font-size: 0.84rem;
  color: var(--ink-soft);
}

/* ------------------------------------------------------------------------------
 * 3. PAINEL DO ADMINISTRADOR (admin.html)
 * ------------------------------------------------------------------------------ */
.admin-page {
  min-height: 100vh;
  background: #f8faf9;
}

.admin-header {
  border-bottom: 1px solid var(--line);
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.admin-badge {
  color: var(--green-700) !important;
  font-weight: 700 !important;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--green-50);
  border: 1px solid var(--green-200);
  padding: 5px 12px 5px 6px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--green-700);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 800;
}

.admin-main {
  padding: 32px 0 64px 0;
}

/* ------------------------------------------------------------------------------
 * 4. CARDS DE MÉTRICAS (STATS)
 * ------------------------------------------------------------------------------ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.stat-icon-green { background: var(--green-100); }
.stat-icon-blue { background: #e0f2fe; }
.stat-icon-amber { background: #fef3c7; }
.stat-icon-purple { background: #ede9fe; }

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.1;
}

/* ------------------------------------------------------------------------------
 * 5. BARRA DE FERRAMENTAS E TABELA
 * ------------------------------------------------------------------------------ */
.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 240px;
}

.search-box .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.search-box input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  font-size: 0.92rem;
}

.search-box input:focus {
  border-color: var(--green-600);
  outline: none;
  box-shadow: 0 0 0 3px rgba(34, 160, 90, 0.15);
}

.filter-group .select-input {
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 0.9rem;
  background-color: var(--white);
}

.table-container {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.92rem;
}

.admin-table th {
  background: var(--green-50);
  padding: 14px 18px;
  font-weight: 700;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.admin-table td {
  padding: 16px 18px;
  border-bottom: 1px solid #edf4f0;
  vertical-align: middle;
}

.admin-table tbody tr:hover {
  background: #fbfdfc;
}

.table-brand-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.restaurant-logo-placeholder {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--green-200);
  color: var(--green-800);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.table-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  color: var(--green-700);
  text-decoration: none;
}

.table-link:hover {
  text-decoration: underline;
}

.table-phone {
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

/* Badges e Status */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-light { background: #f2f4f7; color: #344054; }
.badge-warning { background: #fffaeb; color: #b54708; border: 1px solid #fedf89; }
.badge-danger { background: #fef3f2; color: #b42318; border: 1px solid #fee4e2; }
.badge-muted { background: #f2f4f7; color: var(--muted); }

.status-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.status-toggle-btn.is-active {
  background: #ecfdf3;
  color: #027a48;
  border-color: #a6f4c5;
}

.status-toggle-btn.is-inactive {
  background: #fef3f2;
  color: #b42318;
  border-color: #fecdca;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.action-buttons-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-action {
  background: var(--white);
  border: 1px solid var(--line);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-action:hover {
  background: var(--green-50);
  border-color: var(--green-300);
  color: var(--green-800);
}

.btn-action-accent {
  background: var(--green-100);
  border-color: var(--green-200);
  color: var(--green-800);
}

.btn-action-accent:hover {
  background: var(--green-200);
}

.text-right {
  text-align: right;
}

.loading-cell {
  text-align: center;
  padding: 40px !important;
  color: var(--muted);
}

/* ------------------------------------------------------------------------------
 * 6. MODAIS
 * ------------------------------------------------------------------------------ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 38, 28, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-dialog {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.modal-dialog-lg {
  max-width: 640px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
}

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

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
}

.modal-close:hover {
  color: var(--ink);
  background: var(--green-50);
}

.modal-form,
.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  background: #fafcfb;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.fields-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.slug-input-wrapper {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #f8faf9;
  overflow: hidden;
}

.slug-prefix {
  padding: 10px 0 10px 12px;
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
}

.slug-input-wrapper input {
  border: none !important;
  background: transparent !important;
  padding-left: 4px !important;
  box-shadow: none !important;
}

/* Modal Convite Específico */
.convite-card {
  background: var(--green-50);
  border: 1px solid var(--green-200);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}

.convite-badge-icon {
  font-size: 2.2rem;
  display: block;
  margin-bottom: 8px;
}

.convite-desc {
  font-size: 0.92rem;
  color: var(--ink-soft);
  margin-bottom: 16px;
}

.convite-code-display {
  background: var(--white);
  border: 1px dashed var(--green-600);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-bottom: 16px;
}

.convite-code-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.convite-code-value {
  font-size: 1.4rem;
  letter-spacing: 0.15em;
  color: var(--green-800);
}

.convite-link-box {
  display: flex;
  gap: 8px;
}

.convite-link-box input {
  flex: 1;
  padding: 10px 12px;
  font-size: 0.85rem;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

/* ------------------------------------------------------------------------------
 * 7. QR CODE E PLACA DE MESA FORMATO A6 (105mm x 148mm)
 * ------------------------------------------------------------------------------ */
.qr-preview-container {
  display: flex;
  justify-content: center;
  padding: 12px 0;
  background: #f2f5f3;
  border-radius: var(--radius);
}

/* Layout do cartão de mesa na proporção A6 (105 x 148 mm) */
.mesa-a6-sheet {
  width: 280px;
  height: 395px; /* Proporção A6 */
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
  border: 1px solid var(--line);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  box-sizing: border-box;
}

.mesa-a6-header {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.mesa-a6-logo {
  width: 44px;
  height: 44px;
  margin-bottom: 6px;
}

.mesa-a6-name {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.2;
}

.mesa-a6-subtitle {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--green-700);
  font-weight: 700;
}

.mesa-a6-qr-box {
  background: var(--white);
  padding: 8px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  border: 1px solid #eee;
}

.mesa-a6-qr-box canvas {
  display: block;
  width: 170px !important;
  height: 170px !important;
}

.mesa-a6-footer {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mesa-a6-cta {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--ink);
}

.mesa-a6-subcta {
  font-size: 0.78rem;
  color: var(--green-700);
  font-weight: 600;
}

.mesa-a6-url {
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 4px;
}

.qr-download-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 12px;
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  border-top-color: currentColor;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ------------------------------------------------------------------------------
 * 8. ESTILOS DE IMPRESSÃO A6 DIRETA (window.print())
 * ------------------------------------------------------------------------------ */
@media print {
  @page {
    size: 105mm 148mm; /* Formato A6 */
    margin: 0;
  }

  body * {
    visibility: hidden;
  }

  .modal-overlay,
  .modal-dialog,
  .modal-body,
  .qr-preview-container,
  #mesaA6Sheet,
  #mesaA6Sheet * {
    visibility: visible !important;
  }

  body {
    background: transparent !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .modal-overlay {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 105mm !important;
    height: 148mm !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    display: block !important;
  }

  .modal-dialog {
    max-width: 100% !important;
    max-height: 100% !important;
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .modal-header,
  .modal-footer,
  .qr-download-buttons {
    display: none !important;
  }

  .qr-preview-container {
    background: transparent !important;
    padding: 0 !important;
  }

  #mesaA6Sheet {
    width: 105mm !important;
    height: 148mm !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 16mm 10mm !important;
    box-sizing: border-box !important;
  }

  .mesa-a6-logo {
    width: 18mm !important;
    height: 18mm !important;
  }

  .mesa-a6-name {
    font-size: 16pt !important;
  }

  .mesa-a6-qr-box canvas {
    width: 55mm !important;
    height: 55mm !important;
  }
}
