/* ═══════════════════════════════════════════════════════════════════════════
   REDBIRD CRM — Design System
   Brand colors extracted from logo: cardinal red · near-black · gold · ice
   ═══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ─── Design Tokens ──────────────────────────────────────────────────────── */
:root {
  /* ── Brand ── */
  --brand:          #CC1E1E;
  --brand-dark:     #9B1515;
  --brand-deeper:   #6B0E0E;
  --brand-light:    rgba(204, 30, 30, 0.10);
  --brand-glow:     rgba(204, 30, 30, 0.20);
  --gold:           #C49A14;
  --gold-light:     rgba(196, 154, 20, 0.12);
  --ice:            #C8DDE8;

  /* ── Sidebar ── */
  --sidebar-bg:     #0B0B0B;
  --sidebar-border: rgba(255,255,255,0.06);
  --sidebar-text:   rgba(255,255,255,0.55);
  --sidebar-hover:  rgba(255,255,255,0.07);
  --sidebar-active: rgba(204, 30, 30, 0.14);

  /* ── Surfaces ── */
  --surface:        #ffffff;
  --surface-alt:    #F4F6F9;
  --surface-hover:  #EEF1F6;
  --border:         #E2E8F0;
  --border-strong:  #CBD5E1;

  /* ── Text ── */
  --text-primary:   #0F172A;
  --text-secondary: #475569;
  --text-muted:     #94A3B8;

  /* ── Shadows ── */
  --shadow-xs:  0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm:  0 1px 4px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg:  0 16px 48px rgba(0,0,0,0.18);
  --shadow-red: 0 4px 16px rgba(204,30,30,0.28);

  /* ── Radii ── */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;

  /* ── Transitions ── */
  --ease: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: var(--surface-alt);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { transition: color var(--ease); }

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  width: 252px;
  min-height: 100vh;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
  background-color: var(--sidebar-bg) !important;
  border-right: 1px solid var(--sidebar-border);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 99px; }

/* Brand area */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.35rem 0.5rem 0.85rem;
  text-decoration: none;
  border-radius: var(--r-md);
  transition: background var(--ease);
}
.sidebar-brand:hover { background: rgba(255,255,255,0.05); }

.brand-icon {
  width: 36px;
  height: 36px;
  background: #1C1C1C;
  border: 1px solid rgba(204,30,30,0.35);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 14px rgba(204,30,30,0.25);
  overflow: hidden;
  padding: 2px;
}
.brand-icon img, .brand-icon svg { width: 100%; height: 100%; object-fit: contain; }

.brand-name {
  font-size: 0.95rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.015em;
  line-height: 1.1;
}
.brand-tagline {
  font-size: 0.62rem;
  color: rgba(255,255,255,0.35);
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  display: block;
}

/* Section labels */
.sidebar-section {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.25);
  padding: 0.9rem 0.75rem 0.3rem;
  display: block;
}

/* Nav links */
.sidebar .nav-link {
  border-radius: var(--r-sm);
  padding: 0.48rem 0.75rem;
  font-size: 0.855rem;
  font-weight: 450;
  color: var(--sidebar-text);
  display: flex;
  align-items: center;
  transition: color var(--ease), background var(--ease);
  position: relative;
  margin-bottom: 1px;
}
.sidebar .nav-link i {
  width: 20px;
  text-align: center;
  margin-right: 0.6rem;
  opacity: 0.7;
  font-size: 0.95rem;
  transition: opacity var(--ease);
}
.sidebar .nav-link:hover {
  color: rgba(255,255,255,0.9);
  background: var(--sidebar-hover);
}
.sidebar .nav-link:hover i { opacity: 1; }

.sidebar .nav-link.active {
  color: #fff;
  background: var(--sidebar-active);
  font-weight: 600;
}
.sidebar .nav-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 15%; height: 70%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--brand);
}
.sidebar .nav-link.active i { opacity: 1; color: #fca5a5; }

/* Sidebar divider */
.sidebar hr { border-color: var(--sidebar-border); margin: 0.4rem 0; }

/* Sidebar footer */
.sidebar-footer { border-top: 1px solid var(--sidebar-border); padding-top: 0.5rem; margin-top: auto; }

.sidebar .nav-link.text-white-50 { color: rgba(255,255,255,0.3) !important; }
.sidebar .nav-link.text-white-50:hover { color: rgba(255,255,255,0.6) !important; background: rgba(255,255,255,0.04); }

/* ─── Main content ───────────────────────────────────────────────────────── */
.main-content {
  min-height: 100vh;
  background-color: var(--surface-alt);
}

/* ─── Page header ────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.page-header h1, .page-header .h3 {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.025em;
  margin: 0;
}
.page-header-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ─── Alerts ─────────────────────────────────────────────────────────────── */
.alert {
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: 0.875rem;
  padding: 0.75rem 1rem;
}
.alert-warning {
  background: #FFF8E8;
  border-color: #F5C842;
  color: #7A5A00;
}
.alert-danger {
  background: #FEF1F1;
  border-color: #FAAEB0;
  color: #9B1515;
}
.alert-success {
  background: #F0FDF4;
  border-color: #86EFAC;
  color: #15803D;
}
.alert-info {
  background: #EFF6FF;
  border-color: #93C5FD;
  color: #1E40AF;
}

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  background: var(--surface);
  transition: box-shadow 200ms ease, transform 200ms ease;
}
.stat-card {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  background: var(--surface);
  transition: box-shadow 200ms ease, transform 200ms ease;
}
.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.stat-card .card-body { padding: 1.4rem 1.5rem; }

/* KPI stat cards */
.kpi-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}
.kpi-icon-red   { background: rgba(204,30,30,0.10);   color: var(--brand); }
.kpi-icon-green { background: rgba(22,163,74,0.10);   color: #16A34A; }
.kpi-icon-amber { background: rgba(196,154,20,0.12);  color: var(--gold); }
.kpi-icon-blue  { background: rgba(37,99,235,0.10);   color: #2563EB; }
.kpi-icon-slate { background: rgba(71,85,105,0.10);   color: var(--text-secondary); }

.stat-value {
  font-size: 1.9rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
}
.stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
  margin-bottom: 0.3rem;
}
.stat-delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 99px;
  margin-top: 4px;
}
.stat-delta.up   { background: rgba(22,163,74,0.10); color: #16A34A; }
.stat-delta.down { background: rgba(204,30,30,0.10); color: var(--brand); }

/* Section card header */
.card-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.card-section-header h6 {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.01em;
}

/* ─── Tables ─────────────────────────────────────────────────────────────── */
.table {
  font-size: 0.875rem;
  color: var(--text-primary);
  margin: 0;
}
.table th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  font-weight: 700;
  border-bottom: 2px solid var(--border);
  padding: 0.85rem 0.9rem;
  white-space: nowrap;
  background: transparent;
}
.table td {
  padding: 0.8rem 0.9rem;
  vertical-align: middle;
  border-bottom: 1px solid #F1F5F9;
  color: var(--text-secondary);
}
.table tbody tr:last-child td { border-bottom: none; }

.table-hover tbody tr { transition: background var(--ease); }
.table-hover tbody tr:hover { background-color: var(--surface-hover) !important; }
.table-hover tbody tr:hover td { color: var(--text-primary); }

.table-light thead th { background-color: var(--surface-alt) !important; }

tfoot.table-light td {
  background: var(--surface-alt) !important;
  border-top: 2px solid var(--border);
  font-weight: 700;
  color: var(--text-primary);
}

/* ─── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  font-size: 0.7rem;
  padding: 0.3em 0.7em;
  border-radius: 99px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.badge-status {
  font-size: 0.7rem;
  padding: 0.3em 0.7em;
  border-radius: 99px;
  font-weight: 600;
}
/* Semantic badge overrides — softer palette */
.badge.bg-success   { background: #DCFCE7 !important; color: #15803D !important; }
.badge.bg-danger    { background: #FEE2E2 !important; color: #CC1E1E !important; }
.badge.bg-warning   { background: #FEF9C3 !important; color: #A16207 !important; }
.badge.bg-warning.text-dark { color: #A16207 !important; }
.badge.bg-primary   { background: #DBEAFE !important; color: #1D4ED8 !important; }
.badge.bg-info      { background: #E0F2FE !important; color: #0369A1 !important; }
.badge.bg-info.text-dark { color: #0369A1 !important; }
.badge.bg-secondary { background: #F1F5F9 !important; color: #475569 !important; }

/* ─── Filter bar ─────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.6rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  margin-bottom: 1rem;
}
.filter-bar .form-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  border-radius: var(--r-sm);
  font-size: 0.875rem;
  font-weight: 600;
  transition: all var(--ease);
  letter-spacing: 0.01em;
}
.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
  box-shadow: 0 1px 4px rgba(204,30,30,0.25);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  color: white;
  box-shadow: var(--shadow-red);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

.btn-success {
  background: #16A34A;
  border-color: #16A34A;
  box-shadow: 0 1px 4px rgba(22,163,74,0.2);
}
.btn-success:hover { background: #15803D; border-color: #15803D; box-shadow: 0 4px 12px rgba(22,163,74,0.3); transform: translateY(-1px); }

.btn-outline-primary { color: var(--brand); border-color: var(--brand); }
.btn-outline-primary:hover { background: var(--brand); border-color: var(--brand); color: white; }

.btn-outline-secondary {
  color: var(--text-secondary);
  border-color: var(--border-strong);
  background: var(--surface);
}
.btn-outline-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.btn-outline-danger { color: var(--brand); border-color: #FECACA; }
.btn-outline-danger:hover { background: var(--brand); border-color: var(--brand); color: white; }

.btn-outline-success { color: #16A34A; border-color: #BBF7D0; }
.btn-outline-success:hover { background: #16A34A; border-color: #16A34A; color: white; }

.btn-sm { padding: 0.32rem 0.7rem; font-size: 0.8rem; }

/* ─── Forms ──────────────────────────────────────────────────────────────── */
.form-label {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}
.form-control, .form-select {
  border-radius: var(--r-sm);
  border-color: var(--border-strong);
  font-size: 0.875rem;
  color: var(--text-primary);
  background: var(--surface);
  transition: border-color var(--ease), box-shadow var(--ease);
  padding: 0.52rem 0.8rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-light);
  outline: none;
}
.form-control::placeholder { color: var(--text-muted); }
.form-control-sm, .form-select-sm { padding: 0.3rem 0.65rem; font-size: 0.8rem; }

.required::after { content: " *"; color: var(--brand); }

.form-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.form-section-title::before {
  content: '';
  width: 3px;
  height: 14px;
  background: var(--brand);
  border-radius: 2px;
  flex-shrink: 0;
}

/* Modal improvements */
.modal-content { border-radius: var(--r-lg); border: none; box-shadow: var(--shadow-lg); }
.modal-header { padding: 1rem 1.25rem; border-color: var(--border); }
.modal-footer { padding: 0.75rem 1.25rem; border-color: var(--border); }
.modal-title { font-weight: 700; font-size: 0.95rem; }

/* ─── Progress ───────────────────────────────────────────────────────────── */
.progress { border-radius: 99px; background: #F1F5F9; }
.hours-bar { height: 5px; border-radius: 99px; }
.progress-bar { border-radius: 99px; background: var(--brand); }

/* ─── Login page ─────────────────────────────────────────────────────────── */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sidebar-bg);
  background-image:
    radial-gradient(ellipse 800px 600px at 20% 30%, rgba(204,30,30,0.15) 0%, transparent 70%),
    radial-gradient(ellipse 600px 500px at 80% 80%, rgba(150,20,20,0.10) 0%, transparent 70%);
  padding: 2rem;
}
.login-card {
  width: 100%;
  max-width: 400px;
  border-radius: var(--r-xl) !important;
  border: 1px solid rgba(255,255,255,0.08) !important;
  box-shadow: var(--shadow-lg) !important;
  background: rgba(255,255,255,0.97) !important;
  backdrop-filter: blur(20px);
  padding: 2.5rem !important;
}

/* ─── Invoice header ─────────────────────────────────────────────────────── */
.invoice-header {
  background: linear-gradient(135deg, #1a56db 0%, #1e40af 100%);
  color: white;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 1.5rem;
}
.cae-badge { font-family: monospace; font-size: 1.1rem; letter-spacing: 0.1em; }

/* ─── Timer widget ───────────────────────────────────────────────────────── */
.timer-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--brand);
  animation: pulse 1.4s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.3; transform: scale(0.75); }
}
#timer-widget .btn-outline-light {
  border-color: rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.7);
  font-size: 0.8rem;
  font-weight: 500;
}
#timer-widget .btn-outline-light:hover {
  background: rgba(255,255,255,0.1);
  color: white;
}

/* ─── Empty state ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
}
.empty-state-icon {
  width: 56px; height: 56px;
  background: var(--surface-alt);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  font-size: 1.4rem;
  color: var(--text-muted);
}
.empty-state p { color: var(--text-muted); font-size: 0.875rem; margin: 0; }

/* ─── Report export cards ────────────────────────────────────────────────── */
.export-card-icon {
  width: 40px; height: 40px;
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; margin-bottom: 0.75rem;
}

.report-exp-icon {
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* ─── Misc utility ───────────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted) !important; }
.border-bottom { border-color: var(--border) !important; }
.font-monospace { font-size: 0.85em; }
small, .small { font-size: 0.8rem; }
.fw-semibold { font-weight: 600; }

/* Page title in header area */
.main-content > .d-flex:first-child h1,
.main-content > .d-flex:first-child .h3 {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text-primary);
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 64px; }
  .brand-name, .brand-tagline,
  .sidebar-section,
  .sidebar .nav-link span { display: none; }
  .sidebar .nav-link { justify-content: center; padding: 0.6rem; }
  .sidebar .nav-link i { margin-right: 0; width: auto; font-size: 1.1rem; }
  .sidebar .nav-link.active::before { top: 0; height: 100%; }
  .sidebar-brand { justify-content: center; padding: 0.5rem; }
  .brand-icon { width: 32px; height: 32px; }
}

/* ─────────────────────────────────────────────────────────────────────────
   Table tools: filter pills + global search + sortable headers
   Aplicado a todos los listados (invoices, clients, time-entries, etc.)
   ───────────────────────────────────────────────────────────────────────── */
.filter-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  color: var(--text-secondary, #64748b);
  transition: all 150ms ease;
  font-size: 0.875rem;
}
.filter-pill:hover {
  border-color: var(--brand, #cc1e1e);
  color: var(--text-primary, #1e293b);
}
.filter-pill.is-active {
  background: rgba(204,30,30,0.04);
  border-color: var(--brand, #cc1e1e);
  color: var(--brand, #cc1e1e);
  font-weight: 500;
}
.filter-pill > i:first-child { font-size: 0.9rem; opacity: 0.8; line-height: 1; }
.filter-pill .chevron { font-size: 0.7rem; opacity: 0.6; line-height: 1; }
.filter-pill select {
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  background: transparent !important;
  background-image: none !important;
  border: 0 !important;
  outline: none !important;
  box-shadow: none !important;
  padding: 0 4px !important;
  margin: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  min-width: 80px;
  text-indent: 0;
  line-height: 1.2;
}
.filter-pill select::-ms-expand { display: none; }
.filter-pill select:focus { outline: 0 !important; box-shadow: none !important; }

/* Buscador global */
.search-input {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  padding: 6px 10px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.search-input:focus-within {
  border-color: var(--brand, #cc1e1e);
  box-shadow: 0 0 0 3px rgba(204,30,30,0.08);
}
.search-input .search-icon { color: #94a3b8; font-size: 0.95rem; margin-right: 6px; }
.search-input input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 0.875rem;
  padding: 2px 0;
}
.search-input input::placeholder { color: #94a3b8; }
.search-clear {
  border: 0; background: transparent; color: #94a3b8;
  padding: 0 4px; cursor: pointer; font-size: 1rem;
}
.search-clear:hover { color: var(--brand, #cc1e1e); }

/* Sort en headers */
.data-table th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.data-table th.sortable:hover { background-color: rgba(0,0,0,0.03); }
.data-table th.sortable .sort-icon {
  font-size: 0.7rem;
  opacity: 0.35;
  margin-left: 4px;
  transition: opacity 150ms ease;
}
.data-table th.sortable[data-dir="asc"] .sort-icon::before { content: "\f12c"; opacity: 1; }
.data-table th.sortable[data-dir="desc"] .sort-icon::before { content: "\f128"; opacity: 1; }
.data-table th.sortable[data-dir="asc"] .sort-icon,
.data-table th.sortable[data-dir="desc"] .sort-icon { opacity: 1; color: var(--brand, #cc1e1e); }
