/* ═══════════════════════════════════════════════════════════════
   ClouDental — Folha de estilos global
═══════════════════════════════════════════════════════════════ */

:root {
  --cd-primary:     #0ea5e9;
  --cd-primary-dk:  #0284c7;
  --cd-sidebar-bg:  #0f172a;
  --cd-sidebar-w:   240px;
  --cd-topbar-h:    60px;
  --cd-bg:          #f1f5f9;
  --cd-card-bg:     #ffffff;
  --cd-border:      #e2e8f0;
  --cd-text:        #1e293b;
  --cd-muted:       #64748b;
  --cd-success:     #10b981;
  --cd-warning:     #f59e0b;
  --cd-danger:      #ef4444;
  --cd-info:        #38bdf8;
  --cd-radius:      10px;
}

* { box-sizing: border-box; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--cd-bg);
  color: var(--cd-text);
  margin: 0;
  min-height: 100vh;
}

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

.main-content {
  flex: 1;
  margin-left: var(--cd-sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.page-body {
  padding: 24px;
  flex: 1;
}

/* ── SIDEBAR ──────────────────────────────────────────────────── */
.sidebar {
  width: var(--cd-sidebar-w);
  background: var(--cd-sidebar-bg);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1000;
  overflow-y: auto;
  transition: transform .25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
  letter-spacing: .3px;
}

.sidebar-nav {
  list-style: none;
  padding: 12px 0;
  margin: 0;
}

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  font-size: .88rem;
  font-weight: 500;
  border-radius: 8px;
  margin: 2px 8px;
  transition: background .15s, color .15s;
}

.sidebar-nav li a:hover,
.sidebar-nav li a.active {
  background: rgba(14,165,233,.18);
  color: #fff;
}

.sidebar-nav li a.active {
  background: var(--cd-primary);
}

.sidebar-nav li a i { font-size: 1rem; width: 18px; }

.sidebar-divider {
  border-top: 1px solid rgba(255,255,255,.08);
  margin: 8px 18px !important;
  padding: 0 !important;
}

.sidebar-user {
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--cd-primary);
  color: #fff;
  font-weight: 700;
  font-size: .95rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sidebar-user-name {
  color: #fff;
  font-size: .82rem;
  font-weight: 600;
  line-height: 1.2;
}

.sidebar-user-role {
  color: rgba(255,255,255,.45);
  font-size: .72rem;
  text-transform: capitalize;
}

.btn-sair {
  width: 100%;
  background: rgba(255,255,255,.07);
  border: none;
  color: rgba(255,255,255,.55);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: .8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background .15s, color .15s;
}
.btn-sair:hover { background: rgba(239,68,68,.2); color: #fca5a5; }

/* ── TOPBAR ───────────────────────────────────────────────────── */
.topbar {
  height: var(--cd-topbar-h);
  background: var(--cd-card-bg);
  border-bottom: 1px solid var(--cd-border);
  padding: 0 24px;
  position: sticky; top: 0;
  z-index: 100;
}

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

/* ── CARDS ────────────────────────────────────────────────────── */
.cd-card {
  background: var(--cd-card-bg);
  border: 1px solid var(--cd-border);
  border-radius: var(--cd-radius);
  padding: 20px;
}

.cd-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.cd-card-title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--cd-text);
  margin: 0;
}

/* ── STAT CARDS ───────────────────────────────────────────────── */
.stat-card {
  background: var(--cd-card-bg);
  border: 1px solid var(--cd-border);
  border-radius: var(--cd-radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-icon.blue   { background: #e0f2fe; color: #0284c7; }
.stat-icon.green  { background: #d1fae5; color: #059669; }
.stat-icon.yellow { background: #fef3c7; color: #d97706; }
.stat-icon.red    { background: #fee2e2; color: #dc2626; }

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
  color: var(--cd-text);
}

.stat-label {
  font-size: .78rem;
  color: var(--cd-muted);
  margin-top: 3px;
}

/* ── BADGES DE STATUS ─────────────────────────────────────────── */
.badge-pendente   { background: #fef3c7; color: #92400e; }
.badge-confirmado { background: #d1fae5; color: #065f46; }
.badge-realizado  { background: #dbeafe; color: #1e40af; }
.badge-cancelado  { background: #f3f4f6; color: #6b7280; }
.badge-atrasado   { background: #fee2e2; color: #991b1b; }
.badge-pago       { background: #d1fae5; color: #065f46; }
.badge-orcamento  { background: #ede9fe; color: #5b21b6; }
.badge-aprovado   { background: #d1fae5; color: #065f46; }

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  text-transform: capitalize;
}

/* ── BOTÕES ───────────────────────────────────────────────────── */
.btn-cd-primary {
  background: var(--cd-primary);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  transition: background .15s;
}
.btn-cd-primary:hover { background: var(--cd-primary-dk); color: #fff; }

.btn-cd-outline {
  background: transparent;
  color: var(--cd-primary);
  border: 1px solid var(--cd-primary);
  padding: 7px 15px;
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  transition: all .15s;
}
.btn-cd-outline:hover { background: var(--cd-primary); color: #fff; }

.btn-whatsapp {
  background: #25d366;
  color: #fff;
  border: none;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
  transition: background .15s;
  white-space: nowrap;
}
.btn-whatsapp:hover { background: #1ebe5d; color: #fff; }

/* ── TABELAS ──────────────────────────────────────────────────── */
.cd-table { width: 100%; border-collapse: collapse; }
.cd-table th {
  font-size: .75rem;
  font-weight: 600;
  color: var(--cd-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 10px 14px;
  border-bottom: 2px solid var(--cd-border);
  text-align: left;
}
.cd-table td {
  padding: 12px 14px;
  font-size: .85rem;
  border-bottom: 1px solid var(--cd-border);
  vertical-align: middle;
}
.cd-table tr:last-child td { border-bottom: none; }
.cd-table tbody tr:hover { background: #f8fafc; }

/* ── FORMULÁRIOS ──────────────────────────────────────────────── */
.cd-form-label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--cd-text);
  margin-bottom: 5px;
  display: block;
}

.cd-form-control {
  width: 100%;
  border: 1px solid var(--cd-border);
  border-radius: 7px;
  padding: 8px 12px;
  font-size: .85rem;
  color: var(--cd-text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.cd-form-control:focus {
  border-color: var(--cd-primary);
  box-shadow: 0 0 0 3px rgba(14,165,233,.15);
}

.cd-form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

/* ── AGENDA ───────────────────────────────────────────────────── */
.agenda-slot {
  background: var(--cd-card-bg);
  border: 1px solid var(--cd-border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.agenda-slot-time {
  font-size: .78rem;
  font-weight: 700;
  color: var(--cd-primary);
  min-width: 48px;
  text-align: center;
}

.agenda-slot-info { flex: 1; }
.agenda-slot-name {
  font-weight: 600;
  font-size: .88rem;
}
.agenda-slot-proc {
  font-size: .76rem;
  color: var(--cd-muted);
}

/* ── TIMELINE PRONTUÁRIO ──────────────────────────────────────── */
.timeline { position: relative; padding-left: 24px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 7px; top: 0; bottom: 0;
  width: 2px;
  background: var(--cd-border);
}

.timeline-item { position: relative; margin-bottom: 20px; }
.timeline-dot {
  position: absolute;
  left: -21px; top: 4px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--cd-primary);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--cd-primary);
}

.timeline-date {
  font-size: .73rem;
  color: var(--cd-muted);
  margin-bottom: 4px;
}

.timeline-card {
  background: var(--cd-card-bg);
  border: 1px solid var(--cd-border);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: .85rem;
}

/* ── ALERTAS ──────────────────────────────────────────────────── */
.cd-alert {
  border-radius: 8px;
  padding: 12px 16px;
  font-size: .85rem;
  margin-bottom: 16px;
}
.cd-alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.cd-alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.cd-alert-info { background: #e0f2fe; color: #075985; border: 1px solid #7dd3fc; }

/* ── EMPTY STATE ──────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--cd-muted);
}
.empty-state i { font-size: 3rem; opacity: .3; display: block; margin-bottom: 12px; }
.empty-state p { font-size: .9rem; margin: 0; }

/* ── PAGINAÇÃO / FILTROS ──────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

/* ── LOGIN ────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-box {
  background: #fff;
  border-radius: 14px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo svg { margin-bottom: 10px; }
.login-logo h1 { font-size: 1.5rem; font-weight: 700; color: var(--cd-text); margin: 0; }
.login-logo p  { font-size: .82rem; color: var(--cd-muted); margin: 4px 0 0; }

/* ── RESPONSIVO ───────────────────────────────────────────────── */
.sidebar-toggle { background: none; border: none; cursor: pointer; color: var(--cd-text); padding: 4px; }

/* ── BOTTOM NAV (mobile) ──────────────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--cd-sidebar-bg);
  border-top: 1px solid rgba(255,255,255,.08);
  z-index: 1000;
  padding: 6px 0 env(safe-area-inset-bottom, 6px);
}

.bottom-nav-items {
  display: flex;
  justify-content: space-around;
  align-items: center;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: rgba(255,255,255,.5);
  text-decoration: none;
  font-size: .62rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  transition: color .15s;
  min-width: 52px;
}

.bottom-nav-item i { font-size: 1.2rem; }
.bottom-nav-item.active,
.bottom-nav-item:hover { color: var(--cd-primary); }

/* ── TABELA → CARD (mobile) ───────────────────────────────────── */
@media (max-width: 767.98px) {
  .cd-table-responsive thead { display: none; }
  .cd-table-responsive .cd-table,
  .cd-table-responsive tbody,
  .cd-table-responsive tr,
  .cd-table-responsive td { display: block; width: 100%; }

  .cd-table-responsive tr {
    background: #fff;
    border: 1px solid var(--cd-border);
    border-radius: 10px;
    margin-bottom: 10px;
    padding: 12px 14px;
  }

  .cd-table-responsive tr:hover { background: #f8fafc; }

  .cd-table-responsive td {
    padding: 4px 0;
    border: none;
    font-size: .85rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .cd-table-responsive td::before {
    content: attr(data-label);
    font-size: .72rem;
    font-weight: 700;
    color: var(--cd-muted);
    text-transform: uppercase;
    min-width: 90px;
    flex-shrink: 0;
  }

  .cd-table-responsive td:last-child { margin-top: 6px; justify-content: flex-end; }
  .cd-table-responsive td:last-child::before { display: none; }
}

@media (max-width: 767.98px) {
  /* Layout */
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 999;
  }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-left: 0; }
  .page-body { padding: 14px 12px 80px; }

  /* Bottom nav visível */
  .bottom-nav { display: block; }

  /* Topbar */
  .topbar { padding: 0 14px; }
  .topbar-title { font-size: .9rem; }

  /* Cards e stats */
  .stat-card { padding: 14px; gap: 12px; }
  .stat-value { font-size: 1.3rem; }
  .cd-card { padding: 14px; }

  /* Filtros */
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar form,
  .filter-bar a,
  .filter-bar button { width: 100%; justify-content: center; }

  /* Botões touch-friendly */
  .btn-cd-primary,
  .btn-cd-outline { min-height: 44px; padding: 10px 16px; font-size: .88rem; }

  /* Formulários */
  .cd-form-control,
  .cd-form-select { font-size: 16px; min-height: 44px; padding: 10px 12px; }

  /* Login */
  .login-box { padding: 28px 20px; margin: 12px; border-radius: 12px; }

  /* Agenda semanal → oculta no mobile, mostra a diária */
  .agenda-semana-desktop { display: none !important; }
  .agenda-dia-mobile { display: block !important; }

  /* Orçamento totalizador */
  .orc-total-box { text-align: left !important; }

  /* Prontuário timeline */
  .timeline { padding-left: 18px; }
}

@media (min-width: 768px) {
  .agenda-dia-mobile { display: none !important; }
  .agenda-semana-desktop { display: flex !important; }
}

/* ── UTILS ────────────────────────────────────────────────────── */
.text-money { font-variant-numeric: tabular-nums; font-weight: 600; }
.gap-2 { gap: 8px; }
.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.fw-600 { font-weight: 600; }
.text-muted-sm { font-size: .78rem; color: var(--cd-muted); }
