/**
 * @file public/css/styles.css
 * @description Design System Unificado do Ecossistema CostaSystem (Padrão MedScheduler / BuscaCerta / WhatsWeb):
 *  - Paleta oficial Zinc Dark (#09090B / #18181B / #27272A) + Sky/Blue (#0EA5E9 / #2563EB) com suporte dinâmico White Label (--primary)
 *  - Shell de Área Logada (.med-shell) com Sidebar fixa de 260px + Drawer Mobile responsivo
 *  - Geometria P0 travada de Login/Cadastro (236px, 0px Layout Shift, feedback em top: 71px)
 *  - Proibições P0: Zero spinners numéricos, scrollbars 100% ocultas e blindagem escura input:-webkit-autofill
 */

:root {
  --background: #09090B;
  --foreground: #FAFAFA;

  --bg-base: #09090B;
  --bg-surface: #18181B;
  --bg-card: rgba(24, 24, 27, 0.72);
  --bg-elevated: #27272A;
  --bg-hover: #3F3F46;

  --primary: #0EA5E9;
  --primary-light: #60A5FA;
  --primary-dark: #2563EB;
  --secondary: #0EA5E9;
  --accent: #0EA5E9;
  --wl-primary: #0EA5E9;

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;

  --text-primary: #FAFAFA;
  --text-secondary: #A1A1AA;
  --text-muted: #71717A;

  --border: rgba(255, 255, 255, 0.1);
  --border-hover: rgba(255, 255, 255, 0.2);
  --glass: rgba(24, 24, 27, 0.65);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-glow: 0 0 40px rgba(14, 165, 233, 0.14);
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.42);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

*::-webkit-scrollbar {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-base);
  color: var(--text-primary);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.no-scrollbar {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.no-scrollbar::-webkit-scrollbar {
  display: none;
}

/* Proibição Global P0 (AGENTS.md §5): Zero Scroll Numérico (spinners) */
input[type="number"] {
  -webkit-appearance: none;
  -moz-appearance: textfield;
  appearance: textfield;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Regras de Digitação P0 (AGENTS.md §5): Caixa Baixa vs Caixa Alta */
input[type="email"],
input[inputmode="email"],
input[data-case="lower"],
input[data-mask="domain"],
input[data-mask="slug"] {
  text-transform: lowercase;
}

input.uppercase,
input[data-case="upper"],
textarea[data-case="upper"] {
  text-transform: uppercase;
}

input::placeholder,
textarea::placeholder {
  text-transform: none;
  color: var(--text-muted);
}
input[data-case="upper"]::placeholder {
  text-transform: uppercase;
}

/* Proteção Dark Mode contra Autofill Branco do Chrome/Edge (Padrão MedScheduler / BuscaCerta) */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 40px #18181B inset !important;
  -webkit-text-fill-color: #FAFAFA !important;
  caret-color: #FAFAFA !important;
  transition: background-color 5000s ease-in-out 0s;
}

/* =========================================================================
   SHELL UNIFICADO DA ÁREA LOGADA (MedScheduler / BuscaCerta / WhatsWeb)
   ========================================================================= */
.med-shell {
  background-color: var(--bg-base);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
}

.med-shell .hidden {
  display: none !important;
}

.med-shell select option {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.sidebar {
  width: 260px;
  min-height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 40;
  transition: transform 0.28s ease;
}

.sidebar-group-title {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 12px 16px 4px;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 14px;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  margin: 1px 12px;
  cursor: pointer;
  transition: all 0.18s ease;
  text-decoration: none;
  border: 1px solid transparent;
  background: transparent;
  width: calc(100% - 24px);
  text-align: left;
  font-family: inherit;
}

.sidebar-nav-item:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.sidebar-nav-item.active {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.22), rgba(14, 165, 233, 0.18));
  color: var(--primary-light);
  border: 1px solid rgba(96, 165, 250, 0.34);
  font-weight: 600;
}

.page-with-sidebar {
  margin-left: 260px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-base);
  flex: 1;
  min-width: 0;
}

.shell-fixed-header {
  flex-shrink: 0;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  z-index: 25;
}

.shell-fixed-header-inner {
  max-width: 1400px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

.page-scroll-area {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.page-content {
  padding: 22px 28px 48px;
  max-width: 1400px;
}

#sidebar-mobile-toggle,
#sidebar-mobile-close,
#sidebar-mobile-backdrop {
  display: none;
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .page-with-sidebar {
    margin-left: 0;
  }
  .shell-fixed-header {
    padding: 14px 16px 14px 58px;
  }
  .page-content {
    padding: 18px 16px 32px 16px;
  }
  #sidebar-mobile-toggle {
    display: inline-flex !important;
  }
  #sidebar-mobile-close {
    display: inline-flex !important;
  }
  #sidebar-mobile-backdrop.open {
    display: block !important;
  }
}

/* =========================================================================
   GLASSMORPHISM CARDS, FORMULÁRIOS, BOTÕES, TABELAS E MODAIS
   ========================================================================= */
.glass-card,
.bv-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.glass-card-interactive {
  cursor: pointer;
}
.glass-card-interactive:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-card), var(--shadow-glow);
}

.gradient-text {
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.page-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title-date {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 0 0 3px 0;
  text-transform: capitalize;
}

.page-title-heading {
  font-size: 25px;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
}

.page-title-sub {
  color: var(--text-secondary);
  margin: 4px 0 0 0;
  font-size: 13.5px;
}

/* Inputs */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.input-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.input,
.bv-input,
.bv-select,
.bv-textarea {
  width: 100%;
  padding: 9px 12px;
  background: rgba(9, 9, 11, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 13.5px;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  outline: none;
}

.input:focus,
.bv-input:focus,
.bv-select:focus,
.bv-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.16);
}

.input:disabled,
.bv-input:disabled,
.bv-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: rgba(9, 9, 11, 0.9);
}

/* Botões Oficiais (.btn & .bv-btn unificados) */
.btn,
.bv-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 18px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: transform 0.15s ease, box-shadow 0.18s ease, filter 0.15s ease, border-color 0.15s ease, background 0.15s ease;
  text-decoration: none;
}

.btn:hover:not(:disabled),
.bv-btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:active:not(:disabled),
.bv-btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn:disabled,
.bv-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
  transform: none !important;
}

.btn-primary,
.bv-btn-primary,
.bv-btn-blue {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: #ffffff;
  font-weight: 700;
  border-color: rgba(96, 165, 250, 0.35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 4px 16px rgba(37, 99, 235, 0.36);
}

.btn-primary:hover:not(:disabled),
.bv-btn-primary:hover:not(:disabled),
.bv-btn-blue:hover:not(:disabled) {
  filter: brightness(1.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.32), 0 6px 22px rgba(14, 165, 233, 0.46);
}

.btn-secondary,
.bv-btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled),
.bv-btn-secondary:hover:not(:disabled) {
  border-color: var(--border-hover);
  background: var(--bg-hover);
}

.btn-success,
.bv-btn-emerald {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  font-weight: 700;
  border-color: rgba(52, 211, 153, 0.4);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 4px 16px rgba(16, 185, 129, 0.32);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.32);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.25);
  border-color: var(--danger);
}

.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 12px;
}

.btn-lg {
  height: 44px;
  padding: 0 24px;
  font-size: 14.5px;
}

.btn-full {
  width: 100%;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-info    { background: rgba(14, 165, 233, 0.15); color: var(--primary-light); border: 1px solid rgba(14, 165, 233, 0.32); }
.badge-success { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.32); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.32); }
.badge-danger  { background: rgba(239, 68, 68, 0.15);  color: #f87171; border: 1px solid rgba(239, 68, 68, 0.32); }
.badge-neutral { background: rgba(161, 161, 170, 0.14); color: var(--text-secondary); border: 1px solid var(--border); }

/* Tabelas Executivas (MedScheduler / BuscaCerta) */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-card);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.data-table thead th {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table tbody tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  transition: background 0.15s ease;
}

.data-table tbody tr:hover {
  background: rgba(39, 39, 42, 0.55);
}

.data-table tbody tr:last-child {
  border-bottom: none;
}

.data-table tbody td {
  padding: 11px 12px;
  color: var(--text-primary);
  vertical-align: middle;
}

/* Modais (MedScheduler) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-box {
  background: #18181B;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7), var(--shadow-glow);
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
}

/* Seletor Segmentado Compacto de Presets Comerciais */
.bv-preset-group {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  background: #09090B;
  border: 1px solid var(--border);
}

.bv-preset-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border-radius: 7px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: all 0.15s ease;
}

.bv-preset-btn:hover:not(:disabled):not(.is-active) {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.bv-preset-btn.is-active.tone-emerald {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  font-weight: 700;
  border-color: rgba(52, 211, 153, 0.5);
  box-shadow: 0 3px 12px rgba(16, 185, 129, 0.35);
}

.bv-preset-btn.is-active.tone-amber {
  background: linear-gradient(135deg, #2563EB 0%, #0EA5E9 100%);
  color: #ffffff;
  font-weight: 700;
  border-color: rgba(96, 165, 250, 0.5);
  box-shadow: 0 3px 12px rgba(14, 165, 233, 0.38);
}

.bv-preset-btn.is-active.tone-rose {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #ffffff;
  font-weight: 700;
  border-color: rgba(252, 165, 165, 0.45);
  box-shadow: 0 3px 12px rgba(239, 68, 68, 0.35);
}

/* =========================================================================
   PADRÃO OFICIAL P0: LOGIN & CADASTRO (GEOMETRIA TRAVADA 236px — 0px SHIFT)
   ========================================================================= */
.login-card {
  width: 100%;
  max-width: 430px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 38px 36px 30px;
  box-shadow: var(--shadow-card);
}

.auth-forms-stage {
  position: relative;
  height: 236px;
}

.auth-form-pane {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 236px;
  transition: opacity 0.14s ease;
}

.auth-form-pane.is-hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.auth-input-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 18px;
  line-height: 18px;
  margin-bottom: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.auth-input-wrap {
  position: relative;
  height: 44px;
}

.auth-input {
  width: 100%;
  height: 44px;
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 14px;
  padding: 0 14px 0 42px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.16);
}

.auth-btn-primary {
  width: 100%;
  height: 46px;
  border-radius: 12px;
  border: 1px solid rgba(96, 165, 250, 0.35);
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: #ffffff;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.38);
  transition: filter 0.15s ease, transform 0.12s ease;
}

.auth-btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.auth-btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.email-inline-feedback {
  position: absolute;
  left: 2px;
  right: 2px;
  top: 71px;
  font-size: 11px;
  line-height: 1.25;
  font-weight: 600;
  z-index: 10;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.auth-footer-stage {
  height: 48px;
  margin-top: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Animações & Spinners */
.fade-in {
  animation: fadeIn 0.24s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.spinner,
.bv-spinner {
  width: 15px;
  height: 15px;
  border: 2.2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  display: inline-block;
  animation: bvSpin 0.65s linear infinite;
  flex-shrink: 0;
}

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