/* ============================================================
   KAIROS AGENDA — Design System
   Inspirado no Cal.com: dark/light, clean, elegante
   ============================================================ */

/* ── Variáveis de tema ─────────────────────────────────────── */
:root {
  /* Cores primárias */
  --color-primary:       #6366f1; /* Indigo */
  --color-primary-hover: #4f46e5;
  --color-primary-light: #e0e7ff;

  /* Backgrounds */
  --bg-page:       #f9fafb;
  --bg-card:       #ffffff;
  --bg-sidebar:    #111827;
  --bg-input:      #ffffff;
  --bg-hover:      #f3f4f6;
  --bg-muted:      #f1f5f9;

  /* Texto */
  --text-primary:   #111827;
  --text-secondary: #6b7280;
  --text-muted:     #9ca3af;
  --text-inverse:   #ffffff;
  --text-sidebar:   #d1d5db;

  /* Bordas */
  --border:         #e5e7eb;
  --border-focus:   #6366f1;
  --radius-sm:      6px;
  --radius:         10px;
  --radius-lg:      16px;
  --radius-full:    9999px;

  /* Shadows */
  --shadow-sm:   0 1px 2px rgba(0,0,0,.06);
  --shadow:      0 4px 16px rgba(0,0,0,.08);
  --shadow-lg:   0 8px 32px rgba(0,0,0,.12);

  /* Status colors */
  --status-pending:    #f59e0b;
  --status-confirmed:  #6366f1;
  --status-progress:   #3b82f6;
  --status-completed:  #10b981;
  --status-canceled:   #ef4444;
  --status-rescheduled:#8b5cf6;
  --status-noshow:     #f97316;
  --status-blocked:    #6b7280;

  /* Sidebar */
  --sidebar-width: 240px;

  /* Tipografia */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Transições */
  --transition: 150ms cubic-bezier(.4,0,.2,1);
}

/* Dark mode */
[data-theme="dark"] {
  --bg-page:       #0f172a;
  --bg-card:       #1e293b;
  --bg-sidebar:    #0d1117;
  --bg-input:      #1e293b;
  --bg-hover:      #334155;
  --bg-muted:      #1e293b;

  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #64748b;
  --text-sidebar:   #cbd5e1;

  --border:         #334155;
  --border-focus:   #818cf8;

  --color-primary-light: #1e1b4b;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow:    0 4px 16px rgba(0,0,0,.4);
}

/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  font-size: .9375rem;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-page);
  transition: background var(--transition), color var(--transition);
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

/* ── Layout principal ──────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  transition: transform var(--transition);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.25rem 1.25rem .75rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-logo-mark {
  width: 34px; height: 34px;
  background: var(--color-primary);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .875rem; color: #fff;
  flex-shrink: 0;
}

.sidebar-logo-text {
  color: #fff;
  font-weight: 700;
  font-size: .9375rem;
  letter-spacing: -.01em;
}

.sidebar-logo-text span {
  color: var(--color-primary);
}

.sidebar-company {
  padding: .75rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-company-name {
  color: var(--text-sidebar);
  font-size: .75rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-company-plan {
  color: var(--text-muted);
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.sidebar-nav {
  flex: 1;
  padding: .5rem 0;
}

.sidebar-section-label {
  padding: 1rem 1.25rem .25rem;
  font-size: .6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #4b5563;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .5625rem 1.25rem;
  color: var(--text-sidebar);
  font-size: .875rem;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
  text-decoration: none;
}

.sidebar-link:hover {
  background: rgba(255,255,255,.06);
  color: #fff;
  text-decoration: none;
}

.sidebar-link.active {
  background: rgba(99,102,241,.15);
  color: #fff;
  border-right: 2px solid var(--color-primary);
}

.sidebar-link svg {
  width: 18px; height: 18px;
  flex-shrink: 0;
  opacity: .8;
}

.sidebar-link.active svg { opacity: 1; }

.sidebar-footer {
  padding: .75rem 1.25rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,.08);
}

.sidebar-user {
  display: flex; align-items: center; gap: .6rem;
}

.sidebar-avatar {
  width: 32px; height: 32px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: .8125rem; font-weight: 600;
  flex-shrink: 0;
}

.sidebar-user-info { overflow: hidden; }
.sidebar-user-name {
  color: var(--text-sidebar);
  font-size: .8125rem; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-role {
  color: #4b5563; font-size: .7rem; text-transform: capitalize;
}

/* ── Main content ──────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: 60px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky; top: 0; z-index: 50;
}

.topbar-title {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-actions {
  display: flex; align-items: center; gap: .75rem;
}

.page-content {
  flex: 1;
  padding: 1.5rem;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 1.125rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}

.card-title {
  font-size: .9375rem; font-weight: 600;
  color: var(--text-primary);
}

.card-body { padding: 1.25rem; }

/* ── Metric cards (dashboard) ──────────────────────────────── */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex; flex-direction: column; gap: .5rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

.metric-card:hover { box-shadow: var(--shadow); }

.metric-label {
  font-size: .75rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-secondary);
}

.metric-value {
  font-size: 1.75rem; font-weight: 700;
  color: var(--text-primary); letter-spacing: -.02em;
}

.metric-sub {
  font-size: .75rem; color: var(--text-muted);
}

.metric-trend-up   { color: #10b981; font-size: .75rem; font-weight: 600; }
.metric-trend-down { color: #ef4444; font-size: .75rem; font-weight: 600; }

/* ── Botões ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem; font-weight: 500;
  cursor: pointer; border: 1px solid transparent;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.btn-primary:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  text-decoration: none; color: #fff;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--bg-hover);
  text-decoration: none;
}

.btn-danger {
  background: #ef4444; color: #fff; border-color: #ef4444;
}
.btn-danger:hover { background: #dc2626; border-color: #dc2626; text-decoration: none; color: #fff; }

.btn-ghost {
  background: transparent; color: var(--text-secondary); border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); text-decoration: none; }

.btn-sm { padding: .3125rem .75rem; font-size: .8125rem; }
.btn-lg { padding: .6875rem 1.5rem; font-size: 1rem; }
.btn-icon { padding: .5rem; border-radius: var(--radius-sm); }

/* ── Formulários ───────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }

.form-label {
  display: block;
  font-size: .8125rem; font-weight: 500;
  color: var(--text-primary); margin-bottom: .375rem;
}

.form-control {
  width: 100%;
  padding: .5625rem .875rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: .9375rem; font-family: var(--font-sans);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control { cursor: pointer; }

textarea.form-control { resize: vertical; min-height: 90px; }

.form-hint {
  font-size: .75rem; color: var(--text-muted); margin-top: .25rem;
}

.form-error {
  font-size: .75rem; color: #ef4444; margin-top: .25rem;
}

.form-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
}

/* ── Tabelas ────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }

table {
  width: 100%; border-collapse: collapse; font-size: .875rem;
}

thead th {
  padding: .75rem 1rem;
  text-align: left;
  font-size: .75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  background: var(--bg-muted);
  white-space: nowrap;
}

tbody td {
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg-hover); }

/* ── Badges de status ──────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .2rem .6rem;
  border-radius: var(--radius-full);
  font-size: .6875rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
}

.badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: var(--radius-full);
  background: currentColor;
  opacity: .8;
}

.badge-pending    { background: #fef3c7; color: #92400e; }
.badge-confirmed  { background: #e0e7ff; color: #3730a3; }
.badge-progress   { background: #dbeafe; color: #1e40af; }
.badge-completed  { background: #d1fae5; color: #065f46; }
.badge-canceled   { background: #fee2e2; color: #991b1b; }
.badge-rescheduled{ background: #ede9fe; color: #5b21b6; }
.badge-noshow     { background: #ffedd5; color: #9a3412; }
.badge-blocked    { background: #f3f4f6; color: #374151; }

[data-theme="dark"] .badge-pending    { background: #451a03; color: #fbbf24; }
[data-theme="dark"] .badge-confirmed  { background: #1e1b4b; color: #a5b4fc; }
[data-theme="dark"] .badge-completed  { background: #064e3b; color: #6ee7b7; }
[data-theme="dark"] .badge-canceled   { background: #450a0a; color: #fca5a5; }

/* ── Modals ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  opacity: 0; visibility: hidden;
  transition: opacity var(--transition), visibility var(--transition);
}

.modal-overlay.open {
  opacity: 1; visibility: visible;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 500px;
  max-height: 90vh; overflow-y: auto;
  transform: translateY(10px);
  transition: transform var(--transition);
}

.modal-overlay.open .modal { transform: translateY(0); }

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

.modal-title { font-size: 1rem; font-weight: 600; }

.modal-body { padding: 1.5rem; }

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: flex-end; gap: .75rem;
}

/* ── Toast notifications ────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  z-index: 999; display: flex; flex-direction: column; gap: .5rem;
}

.toast {
  display: flex; align-items: center; gap: .75rem;
  padding: .875rem 1.125rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: .875rem; max-width: 360px;
  animation: slideInRight .2s ease;
}

.toast-success { border-left: 3px solid #10b981; }
.toast-error   { border-left: 3px solid #ef4444; }
.toast-warning { border-left: 3px solid #f59e0b; }
.toast-info    { border-left: 3px solid #6366f1; }

@keyframes slideInRight {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Alert inline ───────────────────────────────────────────── */
.alert {
  padding: .875rem 1.125rem;
  border-radius: var(--radius-sm);
  font-size: .875rem; margin-bottom: 1rem;
  border: 1px solid transparent;
}
.alert-success { background: #d1fae5; color: #065f46; border-color: #a7f3d0; }
.alert-error   { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.alert-warning { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.alert-info    { background: #e0e7ff; color: #3730a3; border-color: #c7d2fe; }

/* ── Dropdown ───────────────────────────────────────────────── */
.dropdown { position: relative; display: inline-block; }

.dropdown-menu {
  position: absolute; top: calc(100% + 4px); right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 160px; z-index: 150;
  opacity: 0; visibility: hidden;
  transform: translateY(-4px);
  transition: all var(--transition);
}

.dropdown.open .dropdown-menu {
  opacity: 1; visibility: visible; transform: translateY(0);
}

.dropdown-item {
  display: flex; align-items: center; gap: .5rem;
  padding: .5625rem .875rem;
  font-size: .875rem; color: var(--text-primary);
  cursor: pointer;
  transition: background var(--transition);
}
.dropdown-item:hover { background: var(--bg-hover); }
.dropdown-item.danger { color: #ef4444; }
.dropdown-divider { height: 1px; background: var(--border); margin: .25rem 0; }

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 3rem 1.5rem;
}

.empty-state-icon {
  width: 56px; height: 56px;
  background: var(--bg-muted);
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1rem;
  color: var(--text-muted);
}

.empty-state-title {
  font-size: 1rem; font-weight: 600;
  color: var(--text-primary); margin-bottom: .375rem;
}

.empty-state-desc {
  font-size: .875rem; color: var(--text-secondary); margin-bottom: 1.25rem;
}

/* ── Pagination ─────────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; gap: .25rem;
}

.page-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  font-size: .875rem; font-weight: 500;
  cursor: pointer; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-primary);
  transition: all var(--transition);
}
.page-btn:hover { background: var(--bg-hover); }
.page-btn.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.page-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Toggle dark mode ───────────────────────────────────────── */
.theme-toggle {
  width: 38px; height: 22px;
  border-radius: var(--radius-full);
  background: var(--border);
  position: relative; cursor: pointer;
  transition: background var(--transition);
  border: none; outline: none;
}
.theme-toggle.on { background: var(--color-primary); }
.theme-toggle::after {
  content: '';
  width: 16px; height: 16px;
  border-radius: var(--radius-full);
  background: #fff;
  position: absolute; top: 3px; left: 3px;
  transition: transform var(--transition);
  box-shadow: var(--shadow-sm);
}
.theme-toggle.on::after { transform: translateX(16px); }

/* ── Loader ─────────────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--color-primary);
  border-radius: var(--radius-full);
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsivo ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .metric-grid {
    grid-template-columns: 1fr 1fr;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .metric-grid {
    grid-template-columns: 1fr;
  }
  .page-content {
    padding: 1rem;
  }
}
