@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=DM+Serif+Display&display=swap');

:root {
  --primary: #0A4DA1;
  --primary-light: #1E6BD6;
  --primary-dark: #063380;
  --secondary: #00B4D8;
  --accent: #00D4AA;
  --danger: #E63946;
  --warning: #F4A261;
  --success: #2DC653;
  --bg: #F0F4FA;
  --bg-card: #FFFFFF;
  --sidebar-bg: #070E2B;
  --sidebar-text: #A8B4CC;
  --sidebar-active: #1E6BD6;
  --text: #0D1B3E;
  --text-muted: #7A8BA8;
  --border: #DDE4F0;
  --shadow: 0 2px 16px rgba(10,77,161,0.08);
  --shadow-lg: 0 8px 32px rgba(10,77,161,0.14);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 240px;
  --topbar-h: 64px;
}

* { margin:0; padding:0; box-sizing:border-box; }
html { font-size: 14px; }
body { font-family: 'Plus Jakarta Sans', sans-serif; background: var(--bg); color: var(--text); overflow-x: hidden; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

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

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  position: fixed; top:0; left:0; bottom:0;
  z-index: 100;
  transition: width 0.3s ease;
  overflow: hidden;
}
.sidebar.collapsed { width: 64px; }
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .sidebar-header span { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 12px; }
.sidebar.collapsed .nav-item i { margin: 0; }

.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 16px; border-bottom: 1px solid rgba(255,255,255,0.06);
}
.logo { display:flex; align-items:center; gap: 10px; color: white; font-weight: 700; font-size: 1.1rem; white-space: nowrap; }
.logo i { color: var(--secondary); font-size: 1.4rem; }
.sidebar-toggle { background:none; border:none; color: var(--sidebar-text); cursor:pointer; font-size: 1.1rem; padding: 4px; }

.sidebar-nav { flex:1; overflow-y: auto; padding: 12px 0; }
.nav-section { padding: 8px 0; }
.nav-label { display: block; color: rgba(168,180,204,0.5); font-size: 0.65rem; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; padding: 8px 20px 4px; white-space: nowrap; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px;
  color: var(--sidebar-text); text-decoration: none;
  border-radius: 0; transition: all 0.2s;
  white-space: nowrap;
  border-left: 3px solid transparent;
  font-size: 0.88rem; font-weight: 500;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: white; }
.nav-item.active { background: rgba(30,107,214,0.15); color: white; border-left-color: var(--primary-light); }
.nav-item i { width: 18px; text-align: center; font-size: 0.95rem; }

/* Main */
.main-content { margin-left: var(--sidebar-w); flex:1; transition: margin 0.3s ease; }
.main-content.expanded { margin-left: 64px; }

/* Topbar */
.topbar {
  height: var(--topbar-h); background: white;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; border-bottom: 1px solid var(--border);
  position: sticky; top:0; z-index: 50;
  box-shadow: 0 1px 8px rgba(0,0,0,0.06);
}
.topbar-left { display:flex; align-items:center; gap: 16px; }
.menu-btn { background:none; border:none; cursor:pointer; color: var(--text-muted); font-size: 1.1rem; padding: 6px; }
.page-title { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.topbar-right { display:flex; align-items:center; gap: 20px; }
.topbar-date { color: var(--text-muted); font-size: 0.82rem; display:flex; align-items:center; gap: 6px; }
.user-info { display:flex; align-items:center; gap: 10px; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white; font-weight: 700; font-size: 0.9rem;
  display:flex; align-items:center; justify-content:center;
}
.user-details { display:flex; flex-direction:column; }
.user-name { font-size: 0.82rem; font-weight: 600; color: var(--text); }
.user-role { font-size: 0.72rem; color: var(--text-muted); text-transform: capitalize; }

/* Page Content */
.page-content { padding: 24px; }

/* Cards */
.card {
  background: var(--bg-card); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--border);
  overflow: hidden;
}
.card-header {
  padding: 18px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: 0.95rem; font-weight: 700; color: var(--text); }
.card-body { padding: 20px; }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: white; border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); border: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-icon {
  width: 52px; height: 52px; border-radius: var(--radius-sm);
  display: flex; align-items:center; justify-content:center;
  font-size: 1.3rem;
}
.stat-icon.blue { background: rgba(10,77,161,0.1); color: var(--primary); }
.stat-icon.cyan { background: rgba(0,180,216,0.1); color: var(--secondary); }
.stat-icon.green { background: rgba(45,198,83,0.1); color: var(--success); }
.stat-icon.orange { background: rgba(244,162,97,0.1); color: var(--warning); }
.stat-icon.red { background: rgba(230,57,70,0.1); color: var(--danger); }
.stat-icon.purple { background: rgba(114,9,183,0.1); color: #7209b7; }
.stat-value { font-size: 1.6rem; font-weight: 800; color: var(--text); }
.stat-label { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; }

/* Buttons */
.btn {
  display: inline-flex; align-items:center; gap: 7px;
  padding: 9px 18px; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 0.82rem; font-weight: 600;
  cursor: pointer; border: none; transition: all 0.2s; text-decoration: none;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #25a845; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #c0303b; }
.btn-warning { background: var(--warning); color: white; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-outline { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: white; }
.btn-sm { padding: 5px 12px; font-size: 0.75rem; }
.btn-icon { padding: 7px; width: 32px; height: 32px; justify-content: center; }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 16px; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1/-1; }
label { font-size: 0.78rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
input, select, textarea {
  padding: 9px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 0.88rem; color: var(--text);
  background: white; transition: border 0.2s;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(10,77,161,0.08); }
textarea { resize: vertical; min-height: 80px; }
.form-section { margin-bottom: 24px; }
.form-section-title {
  font-size: 0.75rem; font-weight: 700; color: var(--primary);
  text-transform: uppercase; letter-spacing: 1px;
  padding-bottom: 8px; border-bottom: 2px solid var(--primary);
  margin-bottom: 16px; display: flex; align-items:center; gap: 8px;
}

/* Tables */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  background: var(--bg); color: var(--text-muted);
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  padding: 10px 14px; text-align: left; border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 0.85rem; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(10,77,161,0.02); }
.td-actions { display:flex; gap: 6px; align-items:center; }

/* Badges */
.badge {
  display: inline-flex; align-items:center; padding: 3px 10px;
  border-radius: 20px; font-size: 0.7rem; font-weight: 600;
}
.badge-success { background: rgba(45,198,83,0.12); color: var(--success); }
.badge-danger { background: rgba(230,57,70,0.12); color: var(--danger); }
.badge-warning { background: rgba(244,162,97,0.15); color: #c07a3a; }
.badge-primary { background: rgba(10,77,161,0.1); color: var(--primary); }
.badge-secondary { background: var(--border); color: var(--text-muted); }
.badge-cyan { background: rgba(0,180,216,0.12); color: #0077b6; }
.badge-purple { background: rgba(114,9,183,0.1); color: #7209b7; }

/* Search */
.search-bar { position: relative; }
.search-bar input { padding-left: 36px; }
.search-bar i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }

/* Tabs */
.tabs { display:flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  padding: 10px 20px; background: none; border: none; cursor: pointer;
  font-family: inherit; font-size: 0.85rem; font-weight: 600; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.2s;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* Modal */
.modal-overlay {
  display: none; position: fixed; inset:0;
  background: rgba(7,14,43,0.5); z-index: 1000;
  backdrop-filter: blur(2px);
}
.modal-overlay.show { display: block; }
.modal {
  display: none; position: fixed;
  top: 50%; left: 50%; transform: translate(-50%, -55%) scale(0.95);
  background: white; border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  z-index: 1001; width: 90%; max-width: 640px;
  max-height: 90vh; overflow-y: auto;
  transition: transform 0.25s, opacity 0.25s;
  opacity: 0;
}
.modal.show { display: block; transform: translate(-50%, -50%) scale(1); opacity: 1; }
.modal-header {
  display: flex; align-items:center; justify-content:space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: white; z-index:1;
}
.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal-close { background:none; border:none; font-size: 1.1rem; cursor:pointer; color: var(--text-muted); padding: 4px; }
.modal-body { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); display:flex; justify-content:flex-end; gap: 10px; }

/* Toast */
#toastContainer { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display:flex; flex-direction:column; gap: 8px; }
.toast {
  background: white; border-radius: var(--radius-sm);
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  padding: 12px 18px; min-width: 260px;
  display: flex; align-items:center; gap: 12px;
  border-left: 4px solid var(--primary);
  animation: slideIn 0.3s ease;
  font-size: 0.85rem; font-weight: 500;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
@keyframes slideIn { from { transform: translateX(100%); opacity:0; } to { transform: translateX(0); opacity:1; } }

/* Calendar */
.calendar-wrapper { overflow-x: auto; }
.calendar-header { display:flex; align-items:center; justify-content:space-between; margin-bottom: 20px; }
.calendar-nav { display:flex; align-items:center; gap: 12px; }
.calendar-nav button { background:none; border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 6px 12px; cursor:pointer; font-size: 0.85rem; transition: all 0.2s; }
.calendar-nav button:hover { background: var(--primary); color: white; border-color: var(--primary); }
.calendar-nav h2 { font-size: 1rem; font-weight: 700; min-width: 180px; text-align:center; }

.week-grid { display: grid; grid-template-columns: 60px repeat(7, 1fr); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.week-header { background: var(--bg); padding: 10px 6px; text-align:center; border-bottom: 2px solid var(--border); border-right: 1px solid var(--border); }
.week-header .day-name { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; color: var(--text-muted); }
.week-header .day-num { font-size: 1.1rem; font-weight: 800; color: var(--text); }
.week-header.today .day-num { color: white; background: var(--primary); border-radius: 50%; width: 30px; height: 30px; display:flex; align-items:center; justify-content:center; margin: 2px auto 0; }
.time-col { padding: 0; }
.time-slot { height: 60px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); display:flex; align-items:flex-start; padding: 4px 8px; }
.time-label { font-size: 0.68rem; color: var(--text-muted); font-weight: 600; }
.day-col { position: relative; border-right: 1px solid var(--border); }
.day-col:last-child { border-right: none; }
.day-hour { height: 60px; border-bottom: 1px solid rgba(0,0,0,0.04); }
.appointment-block {
  position: absolute; left: 2px; right: 2px;
  border-radius: 6px; padding: 4px 7px;
  font-size: 0.72rem; cursor: pointer;
  overflow: hidden; z-index: 2;
  transition: transform 0.1s; 
  border-left: 3px solid rgba(0,0,0,0.2);
}
.appointment-block:hover { transform: scale(1.02); z-index: 3; }
.appointment-block .apt-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appointment-block .apt-time { opacity: 0.8; }

/* Odontogram */
.odontogram-container { padding: 20px 0; }
.teeth-row { display:flex; justify-content:center; gap: 4px; margin: 8px 0; }
.tooth-wrapper { display:flex; flex-direction:column; align-items:center; gap: 2px; }
.tooth-num { font-size: 0.65rem; color: var(--text-muted); font-weight: 600; }
.tooth {
  width: 36px; height: 36px; border-radius: 6px;
  border: 2px solid var(--border); background: white;
  cursor: pointer; transition: all 0.15s;
  display: flex; align-items:center; justify-content:center;
  position: relative;
}
.tooth:hover { border-color: var(--primary); transform: scale(1.1); }
.tooth.selected { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(10,77,161,0.2); }
.tooth i { font-size: 0.9rem; color: var(--text-muted); }
.separator { width: 20px; display:flex; align-items:center; justify-content:center; color: var(--text-muted); font-size: 0.7rem; font-weight: 700; }

/* Login Page */
.login-page {
  min-height: 100vh; background: var(--sidebar-bg);
  display: flex; align-items:center; justify-content:center;
  position: relative; overflow: hidden;
}
.login-bg {
  position: absolute; inset:0;
  background: radial-gradient(ellipse at 20% 50%, rgba(30,107,214,0.3) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 20%, rgba(0,180,216,0.2) 0%, transparent 50%);
}
.login-card {
  background: white; border-radius: 20px;
  padding: 48px 40px; width: 100%; max-width: 420px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.3); position: relative; z-index:1;
}
.login-logo { text-align:center; margin-bottom: 32px; }
.login-logo i { font-size: 2.5rem; color: var(--primary); }
.login-logo h1 { font-family: 'DM Serif Display', serif; font-size: 1.8rem; color: var(--text); margin-top: 8px; }
.login-logo p { color: var(--text-muted); font-size: 0.85rem; }
.login-form .form-group { margin-bottom: 18px; }
.login-form input { width: 100%; padding: 12px 14px; font-size: 0.95rem; }
.login-form .btn { width: 100%; padding: 13px; font-size: 0.95rem; margin-top: 8px; justify-content:center; }
.login-error { background: rgba(230,57,70,0.1); color: var(--danger); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 0.85rem; margin-bottom: 16px; display:none; }

/* Financeiro */
.finance-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.finance-card {
  background: white; border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); text-align:center;
}
.finance-card .fc-value { font-size: 1.6rem; font-weight: 800; }
.finance-card .fc-label { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; margin-top: 4px; }
.finance-card.receita .fc-value { color: var(--success); }
.finance-card.despesa .fc-value { color: var(--danger); }
.finance-card.saldo .fc-value { color: var(--primary); }

/* Alerts */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 0.85rem; display:flex; align-items:center; gap: 10px; }
.alert-warning { background: rgba(244,162,97,0.12); color: #b05e1e; border-left: 4px solid var(--warning); }
.alert-info { background: rgba(0,180,216,0.1); color: #005f73; border-left: 4px solid var(--secondary); }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .finance-summary { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}

/* Utils */
.flex { display:flex; } .items-center { align-items:center; } .justify-between { justify-content:space-between; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.mt-4 { margin-top: 16px; }
.text-muted { color: var(--text-muted); }
.text-center { text-align:center; }
.font-bold { font-weight: 700; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.w-full { width: 100%; }
.empty-state { text-align:center; padding: 48px 20px; color: var(--text-muted); }
.empty-state i { font-size: 3rem; opacity: 0.3; margin-bottom: 12px; }
.empty-state p { font-size: 0.9rem; }

/* Nav badge */
.nav-badge {
  background: var(--warning); color: white;
  border-radius: 10px; font-size: 0.6rem; font-weight: 700;
  padding: 1px 6px; margin-left: 4px;
}

/* Print styles */
@media print {
  .sidebar, .topbar, .btn, .no-print { display: none !important; }
  .main-content { margin: 0 !important; }
  .page-content { padding: 0 !important; }
  .print-area { padding: 20px; }
}
.print-doc {
  max-width: 700px; margin: 0 auto;
  font-family: 'Plus Jakarta Sans', sans-serif;
}
.print-header { text-align: center; border-bottom: 2px solid var(--primary); padding-bottom: 16px; margin-bottom: 24px; }
.print-header h2 { font-family: 'DM Serif Display', serif; color: var(--primary); }
.print-footer { border-top: 1px solid var(--border); margin-top: 40px; padding-top: 16px; text-align:center; font-size:0.8rem; color: var(--text-muted); }
.assinatura-linha { border-top: 1px solid #333; width: 260px; margin: 40px auto 0; text-align:center; padding-top: 6px; font-size:0.85rem; }

/* Orçamento status */
.orcamento-card { border-left: 4px solid var(--border); }
.orcamento-card.aprovado { border-left-color: var(--success); }
.orcamento-card.pendente { border-left-color: var(--warning); }
.orcamento-card.recusado { border-left-color: var(--danger); }

/* Fluxo de caixa */
.fluxo-positivo { color: var(--success); font-weight: 700; }
.fluxo-negativo { color: var(--danger); font-weight: 700; }
.fluxo-saldo { background: var(--bg); font-weight: 800; }
