/* ═══════════════════════════════════════════════════════
   INK & LEDGER — Design System for Simples Fatura
   ═══════════════════════════════════════════════════════ */

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

/* ─── Design Tokens ─── */
:root {
  --bg:             #F6F4F0;
  --surface:        #FFFFFF;
  --sidebar-bg:     #1A1A2E;
  --sidebar-hover:  #252542;
  --sidebar-active: #30305A;
  --accent:         #C4956A;
  --accent-light:   #D4AC85;
  --accent-dim:     rgba(196,149,106,0.12);
  --success:        #3D7C56;
  --success-dim:    rgba(61,124,86,0.10);
  --warning:        #D4A843;
  --warning-dim:    rgba(212,168,67,0.10);
  --danger:         #B5423A;
  --danger-dim:     rgba(181,66,58,0.10);
  --info:           #4A7FB5;
  --info-dim:       rgba(74,127,181,0.10);
  --dark:           #343A40;
  --dark-dim:       rgba(52,58,64,0.10);
  --text:           #2D2D2D;
  --text-secondary: #6B6B6B;
  --text-muted:     #9B9B9B;
  --border:         #E8E4DF;
  --border-light:   #F0EDE8;
  --shadow-sm:      0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md:      0 4px 12px rgba(0,0,0,0.05), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-lg:      0 8px 24px rgba(0,0,0,0.06), 0 2px 6px rgba(0,0,0,0.04);
  --radius:         10px;
  --radius-sm:      6px;
  --font-display:   'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-body:      'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:      'DM Mono', 'Fira Code', monospace;
  --sidebar-width:  256px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  background: var(--bg);
  font-family: var(--font-body);
  color: var(--text);
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

/* ─── Animations ─── */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.anim-enter       { animation: fadeSlideUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) both; }
.anim-delay-1     { animation-delay: 0.05s; }
.anim-delay-2     { animation-delay: 0.10s; }
.anim-delay-3     { animation-delay: 0.18s; }
.anim-delay-4     { animation-delay: 0.26s; }
.anim-delay-5     { animation-delay: 0.34s; }
.anim-delay-6     { animation-delay: 0.42s; }

/* ═══════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════ */
.sidebar {
  position: fixed;
  left: 0; top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  color: rgba(255,255,255,0.7);
  display: flex;
  flex-direction: column;
  padding: 0;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar::-webkit-scrollbar       { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.sidebar-brand {
  padding: 28px 24px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-brand h5 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  color: #fff;
  margin: 0;
  letter-spacing: -0.01em;
}
.sidebar-brand h5 i { color: var(--accent); margin-right: 8px; font-size: 1.1rem; }

.sidebar-nav       { flex: 1; padding: 16px 12px; }
.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.6);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
  cursor: pointer;
}
.sidebar-nav .nav-link i.fa-chevron-down {
  margin-left: auto;
  font-size: 0.65rem;
  transition: transform 0.25s ease;
  opacity: 0.5;
}
.sidebar-nav .nav-link[aria-expanded="true"] i.fa-chevron-down { transform: rotate(180deg); }
.sidebar-nav .nav-link:hover  { background: var(--sidebar-hover); color: rgba(255,255,255,0.9); }
.sidebar-nav .nav-link.active { background: var(--sidebar-active); color: #fff; border-left-color: var(--accent); }
.sidebar-nav .nav-link i:first-child { width: 18px; text-align: center; font-size: 0.85rem; opacity: 0.7; }
.sidebar-nav .nav-link.active i:first-child,
.sidebar-nav .nav-link:hover i:first-child { opacity: 1; }

.nav-submenu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding-left: 16px;
}
.nav-submenu.show { max-height: 300px; }
.nav-submenu a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  color: rgba(255,255,255,0.5);
  font-size: 0.82rem;
  font-weight: 400;
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}
.nav-submenu a:hover { color: rgba(255,255,255,0.9); background: rgba(255,255,255,0.05); }
.nav-submenu a i     { width: 16px; text-align: center; font-size: 0.75rem; }

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

/* ═══════════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════════ */
.main-content {
  margin-left: var(--sidebar-width);
  padding: 32px 36px;
  min-height: 100vh;
}

/* ─── Hero header (dashboard-style) ─── */
.hero-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 32px;
  gap: 20px;
  flex-wrap: wrap;
}
.hero-header h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.75rem;
  color: var(--text);
  margin: 0 0 4px;
  letter-spacing: -0.02em;
}
.hero-date {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* ─── Page header (for non-dashboard pages) ─── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-header h1,
.page-header h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.02em;
}
.page-header p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 4px 0 0;
}

/* ─── Pill action buttons ─── */
.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 50px;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: var(--font-body);
  text-decoration: none;
  transition: all 0.2s ease;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
}
.btn-action:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.btn-action.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-action.primary:hover {
  background: var(--accent-light);
  border-color: var(--accent-light);
  color: #fff;
  box-shadow: 0 4px 14px rgba(196,149,106,0.3);
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* ═══════════════════════════════════════════
   STAT STRIP
   ═══════════════════════════════════════════ */
.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  margin-bottom: 28px;
}
.stat-item {
  padding: 24px 28px;
  position: relative;
}
.stat-item:not(:last-child)::after {
  content: '';
  position: absolute;
  right: 0; top: 20%; height: 60%; width: 1px;
  background: var(--border);
}
.stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.stat-number {
  font-family: var(--font-body);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.stat-sub        { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }
.stat-value {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}
.stat-value-label { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

/* ═══════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════ */
.dash-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow 0.25s ease, transform 0.25s ease;
}
.dash-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.dash-card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 10px;
}
.dash-card-header h6 {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
  margin: 0;
}
.dash-card-header .card-icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  flex-shrink: 0;
}
.card-icon.green  { background: var(--success-dim); color: var(--success); }
.card-icon.blue   { background: var(--info-dim);    color: var(--info); }
.card-icon.amber  { background: var(--warning-dim); color: var(--warning); }
.card-icon.red    { background: var(--danger-dim);  color: var(--danger); }
.card-icon.bronze { background: var(--accent-dim);  color: var(--accent); }
.card-icon.dark   { background: var(--dark-dim);    color: var(--dark); }

/* ═══════════════════════════════════════════
   TABLES (custom)
   ═══════════════════════════════════════════ */
.dash-table               { width: 100%; border-collapse: collapse; }
.dash-table thead th {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 10px 22px;
  border-bottom: 1px solid var(--border);
  background: transparent;
}
.dash-table tbody td {
  padding: 11px 22px;
  font-size: 0.84rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-light);
}
.dash-table tbody tr:last-child td { border-bottom: none; }
.dash-table tbody tr               { transition: background 0.15s ease; }
.dash-table tbody tr:hover         { background: rgba(246, 244, 240, 0.6); }
.dash-table .num  { font-family: var(--font-mono); font-weight: 500; color: var(--text); font-size: 0.82rem; }
.dash-table .total { font-family: var(--font-mono); font-weight: 500; font-variant-numeric: tabular-nums; }
.dash-table .empty-row { text-align: center; color: var(--text-muted); font-style: italic; padding: 20px; }

/* ─── Chart containers ─── */
.chart-box { position: relative; height: 240px; padding: 20px 22px; }

/* ─── Section titles ─── */
.section-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text);
  margin: 8px 0 18px;
  letter-spacing: -0.01em;
}

/* ═══════════════════════════════════════════
   STATUS CHIPS & BADGES
   ═══════════════════════════════════════════ */
.status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 12px;
  border-radius: 50px;
  font-size: 0.73rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.status-processada { background: var(--success-dim); color: var(--success); }
.status-perigo     { background: var(--danger-dim);  color: var(--danger); }
.status-alerta     { background: var(--warning-dim); color: #9A7A1F; }
.status-escuro     { background: var(--dark-dim);    color: var(--dark); }
.status-default    { background: rgba(155,155,155,0.1); color: var(--text-muted); }

.badge-ink {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 50px;
  font-size: 0.73rem;
  font-weight: 600;
}
.badge-ink.danger  { background: var(--danger-dim);  color: var(--danger); }
.badge-ink.warning { background: var(--warning-dim); color: #9A7A1F; }
.badge-ink.low     { background: var(--warning-dim); color: var(--warning); }
.badge-ink.success { background: var(--success-dim); color: var(--success); }
.badge-ink.info    { background: var(--info-dim);    color: var(--info); }

/* ═══════════════════════════════════════════
   BOOTSTRAP OVERRIDES
   ═══════════════════════════════════════════ */

/* Buttons */
.btn-primary {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #fff !important;
  font-family: var(--font-body);
  font-weight: 600;
  border-radius: var(--radius-sm);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--accent-light) !important;
  border-color: var(--accent-light) !important;
  box-shadow: 0 4px 14px rgba(196,149,106,0.25) !important;
}
.btn-success {
  background: var(--success) !important;
  border-color: var(--success) !important;
  font-family: var(--font-body);
  font-weight: 600;
  border-radius: var(--radius-sm);
}
.btn-success:hover { background: #347a4d !important; border-color: #347a4d !important; }
.btn-danger {
  background: var(--danger) !important;
  border-color: var(--danger) !important;
  font-family: var(--font-body);
  font-weight: 600;
  border-radius: var(--radius-sm);
}
.btn-outline-primary {
  color: var(--accent) !important;
  border-color: var(--accent) !important;
  font-family: var(--font-body);
  font-weight: 600;
  border-radius: var(--radius-sm);
}
.btn-outline-primary:hover {
  background: var(--accent) !important;
  color: #fff !important;
}
.btn-outline-secondary {
  color: var(--text-secondary) !important;
  border-color: var(--border) !important;
  font-family: var(--font-body);
  font-weight: 600;
  border-radius: var(--radius-sm);
}
.btn-outline-secondary:hover {
  background: var(--text-secondary) !important;
  border-color: var(--text-secondary) !important;
  color: #fff !important;
}

/* Form controls */
.form-control, .form-select {
  font-family: var(--font-body);
  border-color: var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.form-label {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Tables (Bootstrap override) */
.table { font-family: var(--font-body); color: var(--text); }
.table thead th {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom-color: var(--border);
  background: transparent !important;
}
.table-dark thead th,
.thead-dark th {
  background: var(--sidebar-bg) !important;
  color: rgba(255,255,255,0.85) !important;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: none !important;
}
.table td { border-color: var(--border-light); font-size: 0.85rem; }
.table-striped > tbody > tr:nth-of-type(odd) > * {
  background-color: rgba(246,244,240,0.4);
}
.table-hover > tbody > tr:hover > * {
  background-color: rgba(246,244,240,0.7);
}

/* Cards (Bootstrap) */
.card {
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border-light);
  font-family: var(--font-body);
  font-weight: 600;
}
.card-footer {
  background: transparent;
  border-top: 1px solid var(--border-light);
}

/* Alerts */
.alert-success { background: var(--success-dim); color: var(--success); border-color: rgba(61,124,86,0.2); }
.alert-danger  { background: var(--danger-dim);  color: var(--danger);  border-color: rgba(181,66,58,0.2); }
.alert-warning { background: var(--warning-dim); color: #7A5F1A;       border-color: rgba(212,168,67,0.2); }
.alert-info    { background: var(--info-dim);    color: var(--info);    border-color: rgba(74,127,181,0.2); }

/* Badges */
.badge.bg-danger  { background: var(--danger) !important; }
.badge.bg-warning { background: var(--warning) !important; color: #fff !important; }
.badge.bg-success { background: var(--success) !important; }
.badge.bg-primary { background: var(--accent) !important; }
.badge.bg-info    { background: var(--info) !important; }

/* Navbar (legacy top navbar override) */
.navbar { background: var(--surface) !important; box-shadow: var(--shadow-sm); border-bottom: 1px solid var(--border-light); }
.navbar-brand img { filter: none; }
.navbar .nav-link { font-family: var(--font-body); font-weight: 500; color: var(--text-secondary) !important; font-size: 0.88rem; }
.navbar .nav-link:hover { color: var(--accent) !important; }
.navbar .nav-link.active { color: var(--accent) !important; font-weight: 600; }
.dropdown-menu { border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-md); }
.dropdown-item { font-family: var(--font-body); font-size: 0.85rem; }
.dropdown-item:hover { background: var(--accent-dim); color: var(--accent); }

/* Modals */
.modal-content {
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-lg);
}
.modal-header { border-bottom-color: var(--border-light); }
.modal-footer { border-top-color: var(--border-light); }

/* Pagination */
.page-link {
  color: var(--accent);
  border-color: var(--border);
  font-family: var(--font-body);
}
.page-item.active .page-link {
  background: var(--accent);
  border-color: var(--accent);
}

/* ═══════════════════════════════════════════
   GENERAL PAGE CONTAINER (non-sidebar pages)
   ═══════════════════════════════════════════ */
.page-wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 16px;
}

/* ═══════════════════════════════════════════
   LOGIN & STANDALONE PAGE STYLES
   ═══════════════════════════════════════════ */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-width: 420px;
  width: 100%;
  overflow: hidden;
}
.login-card-body  { padding: 36px 32px; }
.login-card-footer {
  padding: 16px 32px;
  border-top: 1px solid var(--border-light);
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.login-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--text);
  margin-bottom: 24px;
}
.login-title i { color: var(--accent); margin-right: 8px; }

/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */
@media (max-width: 1200px) {
  .stat-strip { grid-template-columns: repeat(2, 1fr); }
  .stat-item:nth-child(2)::after { display: none; }
  .stat-item:nth-child(3),
  .stat-item:nth-child(4) { border-top: 1px solid var(--border-light); }
}
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
  }
  .main-content {
    margin-left: 0;
    padding: 20px 16px;
  }
  .stat-strip { grid-template-columns: 1fr; }
  .stat-item::after { display: none !important; }
  .stat-item:not(:first-child) { border-top: 1px solid var(--border-light); }
  .hero-header { flex-direction: column; }
  .chart-box   { height: 200px; }
  .page-header { flex-direction: column; align-items: flex-start; }
}
