/* ============================================================
   SAM — Design System v2.0
   ============================================================ */

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

/* ── CSS Variables ── */
:root {
  --sidebar-from:    #0f2340;
  --sidebar-to:      #1a3a6b;
  --sidebar-width:   240px;
  --navbar-h:        58px;
  --card-radius:     14px;
  --card-shadow:     0 2px 12px rgba(0,0,0,.07);
  --card-shadow-hover: 0 8px 32px rgba(13,110,253,.13);
  --transition:      .22s cubic-bezier(.4,0,.2,1);
  --accent:          #0d6efd;
  --accent-glow:     rgba(13,110,253,.25);
  --font:            'Inter', system-ui, sans-serif;
}

/* ── Animations ──────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(.94); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 var(--accent-glow); }
  70%  { box-shadow: 0 0 0 8px rgba(13,110,253,0); }
  100% { box-shadow: 0 0 0 0 rgba(13,110,253,0); }
}
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}
@keyframes progress-fill {
  from { width: 0 !important; }
}
@keyframes badge-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .6; }
}
@keyframes spin-slow {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

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

html { scroll-behavior: smooth; }

body {
  background: #f0f3f8;
  font-family: var(--font);
  font-size: .9375rem;
  color: #212529;
  overflow-x: hidden;
}

/* ── Page fade-in ── */
main {
  animation: fadeIn .35s ease both;
}

/* ── Navbar ──────────────────────────────────────────────── */
.navbar {
  height: var(--navbar-h);
  background: linear-gradient(135deg, #0d6efd 0%, #0550c0 100%) !important;
  box-shadow: 0 3px 20px rgba(13,110,253,.35);
  backdrop-filter: blur(12px);
  padding: 0 1.25rem;
  position: sticky;
  top: 0;
  z-index: 1040;
}

.navbar-brand {
  font-size: 1.15rem;
  letter-spacing: -.3px;
  gap: 6px;
}

.navbar-brand i {
  animation: float 3s ease-in-out infinite;
  display: inline-block;
}

/* User chip in navbar */
.nav-user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,.15);
  border-radius: 50px;
  padding: 4px 14px 4px 8px;
  backdrop-filter: blur(4px);
}

.nav-avatar {
  width: 30px; height: 30px;
  background: rgba(255,255,255,.25);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  background: linear-gradient(180deg, var(--sidebar-from) 0%, var(--sidebar-to) 100%);
  border: none;
  min-height: calc(100vh - var(--navbar-h));
  width: var(--sidebar-width);
  position: sticky;
  top: var(--navbar-h);
  align-self: flex-start;
  overflow-y: auto;
  padding: 1rem 0;
  box-shadow: 4px 0 30px rgba(0,0,0,.18);
  animation: slideInLeft .4s ease both;
}

.sidebar-section-label {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.35);
  padding: 1rem 1.1rem .3rem;
}

.sidebar .nav-link {
  color: rgba(255,255,255,.65);
  border-radius: 10px;
  margin: 2px 10px;
  padding: 9px 14px;
  font-size: .875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: color var(--transition), background var(--transition), transform var(--transition);
  position: relative;
  overflow: hidden;
}

.sidebar .nav-link i {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  transition: transform var(--transition);
}

.sidebar .nav-link::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.08);
  opacity: 0;
  border-radius: 10px;
  transition: opacity var(--transition);
}

.sidebar .nav-link:hover {
  color: #fff;
  transform: translateX(3px);
}
.sidebar .nav-link:hover::before { opacity: 1; }
.sidebar .nav-link:hover i { transform: scale(1.15); }

.sidebar .nav-link.active {
  background: rgba(255,255,255,.12);
  color: #fff;
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent);
}

.sidebar .nav-link.active i { color: #4da3ff; }

/* Divider in sidebar */
.sidebar hr {
  border-color: rgba(255,255,255,.1);
  margin: .5rem 1rem;
}

/* ── Layout ─────────────────────────────────────────────── */
.content-area {
  flex: 1;
  min-width: 0;
  padding: 1.5rem 1.75rem;
  animation: fadeInUp .4s ease both;
}

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
}
.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #1a2744;
  margin: 0;
  letter-spacing: -.3px;
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
  border: none;
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  transition: box-shadow var(--transition), transform var(--transition);
  animation: fadeInUp .4s ease both;
  overflow: hidden;
}

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

/* Staggered card animation */
.card-stagger > .card:nth-child(1)  { animation-delay: .05s; }
.card-stagger > .card:nth-child(2)  { animation-delay: .10s; }
.card-stagger > .card:nth-child(3)  { animation-delay: .15s; }
.card-stagger > .card:nth-child(4)  { animation-delay: .20s; }
.card-stagger > .card:nth-child(5)  { animation-delay: .25s; }
.card-stagger > .card:nth-child(6)  { animation-delay: .30s; }

.card-header {
  background: transparent;
  border-bottom: 1px solid rgba(0,0,0,.06);
  padding: .9rem 1.1rem;
  font-weight: 600;
  font-size: .875rem;
  color: #344054;
}

.card-body { padding: 1.1rem; }

/* ── KPI Cards ───────────────────────────────────────────── */
.kpi-card {
  border-radius: 16px !important;
  padding: 1.4rem;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
  cursor: default;
  border: none !important;
}
.kpi-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 36px rgba(0,0,0,.12) !important;
}

/* Decorative circle */
.kpi-card::after {
  content: '';
  position: absolute;
  top: -30px; right: -30px;
  width: 110px; height: 110px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  pointer-events: none;
}

.kpi-card .kpi-icon {
  font-size: 2rem;
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.2);
  margin-bottom: .75rem;
}

.kpi-card .kpi-value {
  font-size: 2.1rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -1px;
  color: #fff;
}

.kpi-card .kpi-label {
  font-size: .8rem;
  font-weight: 500;
  color: rgba(255,255,255,.8);
  margin-top: .3rem;
}

/* KPI card themes */
.kpi-primary { background: linear-gradient(135deg, #0d6efd, #4da3ff); }
.kpi-warning { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.kpi-danger  { background: linear-gradient(135deg, #dc3545, #f87171); }
.kpi-success { background: linear-gradient(135deg, #198754, #34d399); }
.kpi-info    { background: linear-gradient(135deg, #0ea5e9, #38bdf8); }
.kpi-purple  { background: linear-gradient(135deg, #7c3aed, #a78bfa); }

/* ── Tables ──────────────────────────────────────────────── */
.table { font-size: .875rem; }

.table thead th {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #6b7280;
  background: #f9fafb;
  border-bottom: 2px solid #e9ecef;
  white-space: nowrap;
  padding: .65rem .9rem;
}

.table tbody td { padding: .7rem .9rem; vertical-align: middle; }

.table-hover tbody tr {
  transition: background var(--transition), transform var(--transition);
  cursor: default;
}
.table-hover tbody tr:hover {
  background: #f0f5ff !important;
  transform: scale(1.002);
}

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  font-weight: 600;
  font-size: .7rem;
  letter-spacing: .02em;
  padding: .3em .65em;
  border-radius: 6px;
}

/* Animated badge for active states */
.badge-pulse {
  animation: badge-pulse 2s ease-in-out infinite;
}

/* Role badges */
.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: .25em .65em;
  border-radius: 6px;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .02em;
}
.role-employee   { background: #e0f2fe; color: #0369a1; }
.role-manager    { background: #fef9c3; color: #92400e; }
.role-it_admin   { background: #ede9fe; color: #5b21b6; }
.role-superadmin { background: #fee2e2; color: #991b1b; }

/* ── Status badges ───────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: .3em .75em;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
}
.status-badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.status-draft       { background: #f1f3f5; color: #6c757d; }
.status-pending     { background: #fff8e1; color: #e65100; }
.status-approved    { background: #e0f2fe; color: #0277bd; }
.status-in_progress { background: #ede9fe; color: #5b21b6; animation: badge-pulse 2s infinite; }
.status-completed   { background: #e8f5e9; color: #1b5e20; }
.status-rejected    { background: #fce4ec; color: #880e4f; }
.status-cancelled   { background: #f3f4f6; color: #374151; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  font-family: var(--font);
  font-weight: 600;
  font-size: .8375rem;
  border-radius: 8px;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

/* Ripple effect */
.btn::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 5px; height: 5px;
  background: rgba(255,255,255,.5);
  border-radius: 50%;
  transform: translate(-50%,-50%) scale(0);
  transition: transform .5s, opacity .5s;
  opacity: 0;
}
.btn:active::after {
  transform: translate(-50%,-50%) scale(30);
  opacity: 0;
  transition: 0s;
}

.btn-primary {
  background: linear-gradient(135deg, #0d6efd, #0550c0);
  border-color: transparent;
  box-shadow: 0 3px 10px rgba(13,110,253,.3);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #1a7aff, #0d6efd);
  box-shadow: 0 5px 18px rgba(13,110,253,.4);
  transform: translateY(-1px);
}

.btn-success {
  background: linear-gradient(135deg, #198754, #0f5c38);
  border-color: transparent;
  box-shadow: 0 3px 10px rgba(25,135,84,.3);
}
.btn-success:hover {
  box-shadow: 0 5px 18px rgba(25,135,84,.4);
  transform: translateY(-1px);
}

.btn-danger {
  background: linear-gradient(135deg, #dc3545, #a3001a);
  border-color: transparent;
  box-shadow: 0 3px 10px rgba(220,53,69,.3);
}
.btn-danger:hover {
  box-shadow: 0 5px 18px rgba(220,53,69,.4);
  transform: translateY(-1px);
}

.btn-outline-primary { border-width: 1.5px; }
.btn-outline-primary:hover { transform: translateY(-1px); }

.btn-sm { font-size: .775rem; padding: .3rem .7rem; }

/* ── Forms ───────────────────────────────────────────────── */
.form-control, .form-select {
  border: 1.5px solid #dee2e6;
  border-radius: 8px;
  font-size: .875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-label { font-weight: 600; font-size: .825rem; color: #344054; margin-bottom: .4rem; }
.form-text  { color: #6b7280; }

/* ── Progress bars ───────────────────────────────────────── */
.progress {
  height: 8px;
  border-radius: 10px;
  background: #e9ecef;
  overflow: hidden;
}
.progress-bar {
  border-radius: 10px;
  animation: progress-fill .9s cubic-bezier(.4,0,.2,1) both;
  transition: width .6s ease;
}

/* ── Alerts ──────────────────────────────────────────────── */
.alert {
  border: none;
  border-radius: 10px;
  font-size: .875rem;
  animation: scaleIn .2s ease both;
}
.alert-warning { background: #fff8e1; color: #92400e; border-left: 4px solid #f59e0b; }
.alert-success { background: #ecfdf5; color: #065f46; border-left: 4px solid #10b981; }
.alert-danger  { background: #fef2f2; color: #991b1b; border-left: 4px solid #ef4444; }
.alert-info    { background: #e0f2fe; color: #0c4a6e; border-left: 4px solid #0ea5e9; }

/* ── List groups ─────────────────────────────────────────── */
.list-group-item {
  border-color: rgba(0,0,0,.05);
  font-size: .875rem;
  transition: background var(--transition);
}
.list-group-item:hover { background: #f8faff; }

/* ── Breadcrumb / back link ─────────────────────────────── */
.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #6b7280;
  font-size: .85rem;
  font-weight: 500;
  text-decoration: none;
  padding: .3rem .6rem;
  border-radius: 6px;
  transition: color var(--transition), background var(--transition);
}
.btn-back:hover { color: var(--accent); background: #f0f4ff; }

/* ── Quick-action cards on dashboard ──────────────────────── */
.quick-action {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: .8rem 1rem;
  border-radius: 10px;
  font-weight: 500;
  font-size: .875rem;
  text-decoration: none;
  color: #344054;
  background: #f9fafb;
  border: 1.5px solid #e9ecef;
  transition: all var(--transition);
}
.quick-action:hover {
  background: #eff6ff;
  border-color: var(--accent);
  color: var(--accent);
  transform: translateX(4px);
}
.quick-action i {
  font-size: 1.2rem;
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* ── Skeleton loader ─────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 800px 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}

/* ── Font mono ───────────────────────────────────────────── */
.font-monospace { font-family: 'Fira Code', 'Courier New', monospace; }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c1c8d0; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 767.98px) {
  .sidebar { display: none; }
  .content-area { padding: 1rem; }
}

/* ── Login page ──────────────────────────────────────────── */
.login-bg {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f2340 0%, #1a3a6b 40%, #0d6efd 100%);
  position: relative;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}

/* Floating orbs */
.login-bg::before, .login-bg::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: .25;
  animation: float 6s ease-in-out infinite;
}
.login-bg::before {
  width: 400px; height: 400px;
  background: #4da3ff;
  top: -100px; left: -100px;
}
.login-bg::after {
  width: 350px; height: 350px;
  background: #7c3aed;
  bottom: -80px; right: -80px;
  animation-delay: -3s;
}

.login-card {
  width: 420px;
  background: rgba(255,255,255,.97);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  box-shadow: 0 25px 80px rgba(0,0,0,.4);
  padding: 2.5rem;
  animation: scaleIn .4s ease both;
  position: relative;
  z-index: 1;
}

.login-logo {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, #0d6efd, #7c3aed);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1rem;
  box-shadow: 0 8px 24px rgba(13,110,253,.4);
  animation: float 3s ease-in-out infinite;
}

/* Decorative dots pattern */
.login-dots {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,.08) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
  z-index: 0;
}

/* ── Utility ─────────────────────────────────────────────── */
.text-muted { color: #6b7280 !important; }
.fw-600 { font-weight: 600; }
.gap-1 { gap: .25rem !important; }
.rounded-lg { border-radius: 12px; }

/* Animated counter */
.counter { transition: all .5s; }

/* Hover lift for action cards */
.hover-lift { transition: transform var(--transition), box-shadow var(--transition); }
.hover-lift:hover { transform: translateY(-3px); box-shadow: var(--card-shadow-hover); }
