/* ============================================================
   LICA Assistant Admin — Premium Dark UI
   ============================================================ */

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

/* ── Design Tokens ────────────────────────────────────────── */
:root {
  --bg-deep: #060b18;
  --bg-base: #0a1128;
  --bg-surface: #111a30;
  --bg-elevated: #162040;
  --bg-hover: #1b2850;

  --border: rgba(99, 130, 200, .12);
  --border-focus: rgba(99, 130, 200, .30);

  --text-primary: #f0f2f8;
  --text-secondary: #94a3c0;
  --text-muted: #5e6e8a;

  --primary: #6366f1;
  --primary-glow: #818cf8;
  --accent: #22d3ee;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;

  --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a78bfa 100%);
  --gradient-success: linear-gradient(135deg, #059669, #34d399);
  --gradient-danger: linear-gradient(135deg, #dc2626, #f87171);
  --gradient-accent: linear-gradient(135deg, #0891b2, #22d3ee);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .45);
  --shadow-glow: 0 0 30px rgba(99, 102, 241, .15);

  --sidebar-w: 260px;
  --topbar-h: 0px;
  --transition: .25s cubic-bezier(.4, 0, .2, 1);
}

/* ── Reset & Base ─────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

/* ── App Shell ────────────────────────────────────────────── */
.app {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #0d1629 0%, #0a1128 100%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
}

.sidebar-header {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-primary);
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  box-shadow: 0 0 20px rgba(99, 102, 241, .35);
}

.sidebar-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.sidebar-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-section {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  padding: 16px 12px 8px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  position: relative;
}

.nav-item:hover {
  background: rgba(99, 130, 200, .08);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(99, 102, 241, .12);
  color: #a5b4fc;
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  border-radius: 0 3px 3px 0;
  background: var(--gradient-primary);
}

.nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  opacity: .8;
}

.nav-item.active .nav-icon {
  opacity: 1;
}

.nav-item.danger-link {
  color: #f87171;
}

.nav-item.danger-link:hover {
  background: rgba(248, 113, 113, .08);
}

/* Sidebar footer */
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.sidebar-footer-text {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

/* ── Main Content ─────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Page Header ──────────────────────────────────────────── */
.page-header {
  padding: 28px 32px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-title-icon {
  font-size: 28px;
}

.page-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Mobile toggle */
.mobile-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 200;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 20px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

/* ── Container ────────────────────────────────────────────── */
.container {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 32px 40px;
  width: 100%;
}

/* ── Grid ─────────────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 20px;
}

.col-3 {
  grid-column: span 3;
}

.col-4 {
  grid-column: span 4;
}

.col-6 {
  grid-column: span 6;
}

.col-8 {
  grid-column: span 8;
}

.col-12 {
  grid-column: span 12;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: linear-gradient(180deg, rgba(17, 26, 48, .95) 0%, rgba(13, 22, 41, .98) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  backdrop-filter: blur(12px);
  transition: transform var(--transition), box-shadow var(--transition);
}

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

.card .head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.card .title {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
}

.card .body {
  padding: 22px;
}

/* ── Stat Cards (Dashboard) ───────────────────────────────── */
.stat-card {
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -30%;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  opacity: .06;
  pointer-events: none;
}

.stat-card.purple::before {
  background: #6366f1;
}

.stat-card.cyan::before {
  background: #22d3ee;
}

.stat-card.amber::before {
  background: #fbbf24;
}

.stat-card.emerald::before {
  background: #34d399;
}

.stat-card .stat-icon {
  font-size: 32px;
  margin-bottom: 12px;
}

.stat-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 36px;
  font-weight: 800;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
}

.stat-card.cyan .stat-value {
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.stat-card.amber .stat-value {
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.stat-card.emerald .stat-value {
  background: var(--gradient-success);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.stat-footer {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ── Metric (legacy compat) ───────────────────────────────── */
.metric {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.metric .value {
  font-size: 28px;
  font-weight: 700;
  color: #fff;
}

.metric .badge {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-focus);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn.primary {
  background: var(--gradient-primary);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(99, 102, 241, .25);
}

.btn.primary:hover {
  box-shadow: 0 6px 20px rgba(99, 102, 241, .4);
  transform: translateY(-2px);
}

.btn.success {
  background: var(--gradient-success);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(52, 211, 153, .2);
}

.btn.success:hover {
  box-shadow: 0 6px 20px rgba(52, 211, 153, .35);
}

.btn.danger {
  background: var(--gradient-danger);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(248, 113, 113, .2);
}

.btn.danger:hover {
  box-shadow: 0 6px 20px rgba(248, 113, 113, .35);
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-md);
}

/* ── Forms ────────────────────────────────────────────────── */
.form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(6, 11, 24, .8);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  transition: all var(--transition);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .15);
  background: rgba(6, 11, 24, .95);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-muted);
}

.textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.6;
}

.select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235e6e8a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ── Inline layout ────────────────────────────────────────── */
.inline {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Tables ───────────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.table thead th {
  background: rgba(15, 23, 42, .6);
  color: var(--text-muted);
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.table thead th:first-child {
  border-radius: var(--radius-md) 0 0 0;
}

.table thead th:last-child {
  border-radius: 0 var(--radius-md) 0 0;
}

.table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(99, 130, 200, .06);
  color: var(--text-secondary);
  vertical-align: middle;
}

.table tbody tr {
  transition: background var(--transition);
}

.table tbody tr:hover {
  background: rgba(99, 130, 200, .05);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.badge.muted {
  background: rgba(94, 110, 138, .12);
  color: var(--text-muted);
}

.badge.ok,
.badge.success-badge {
  background: rgba(52, 211, 153, .1);
  color: var(--success);
}

.badge.error {
  background: rgba(248, 113, 113, .1);
  color: var(--danger);
}

.badge.missing {
  background: rgba(251, 191, 36, .1);
  color: var(--warning);
}

/* ── Status Grid (Health) ─────────────────────────────────── */
.status-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid rgba(99, 130, 200, .06);
}

.status-item:last-child {
  border-bottom: none;
}

.status-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
}

.status-dot.ok {
  background: var(--success);
  box-shadow: 0 0 8px rgba(52, 211, 153, .4);
}

.status-dot.error {
  background: var(--danger);
  box-shadow: 0 0 8px rgba(248, 113, 113, .4);
}

.status-dot.missing {
  background: var(--warning);
  box-shadow: 0 0 8px rgba(251, 191, 36, .4);
}

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  border: 1px solid;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideDown .3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.alert.success {
  background: rgba(5, 150, 105, .1);
  color: #6ee7b7;
  border-color: rgba(52, 211, 153, .2);
}

.alert.danger {
  background: rgba(220, 38, 38, .1);
  color: #fca5a5;
  border-color: rgba(248, 113, 113, .2);
}

.alert.info {
  background: rgba(99, 102, 241, .1);
  color: #a5b4fc;
  border-color: rgba(99, 102, 241, .2);
}

.alert.warning {
  background: rgba(245, 158, 11, .1);
  color: #fcd34d;
  border-color: rgba(251, 191, 36, .2);
}

/* ── Login Hero ───────────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, .08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 50%, rgba(34, 211, 238, .06) 0%, transparent 50%),
    var(--bg-deep);
}

.login-card {
  width: 100%;
  max-width: 420px;
  animation: fadeUp .5s ease;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.login-logo {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 800;
  color: #fff;
  margin: 0 auto 20px;
  box-shadow: 0 0 30px rgba(99, 102, 241, .3);
}

.login-title {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.login-sub {
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.hero {
  max-width: 520px;
  margin: 48px auto;
}

/* ── Utility ──────────────────────────────────────────────── */
.muted {
  color: var(--text-muted);
}

.spacer {
  height: 20px;
}

.center {
  display: flex;
  justify-content: center;
  align-items: center;
}

.text-sm {
  font-size: 13px;
}

.text-xs {
  font-size: 11px;
}

.fw-600 {
  font-weight: 600;
}

/* ── Footer ───────────────────────────────────────────────── */
.footer {
  color: var(--text-muted);
  text-align: center;
  padding: 24px 32px;
  font-size: 12px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(99, 130, 200, .15);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(99, 130, 200, .25);
}

/* ── Responsive ───────────────────────────────────────────── */
@media(max-width:1024px) {
  .col-3 {
    grid-column: span 6;
  }
}

@media(max-width:768px) {
  .sidebar {
    transform: none;
    left: -260px;
    z-index: 1000;
  }

  .sidebar.open {
    transform: none;
    left: 0;
    box-shadow: 20px 0 40px rgba(0, 0, 0, .5);
    z-index: 1200;
  }

  .mobile-toggle {
    display: flex;
    z-index: 1100;
  }

  .main-content {
    margin-left: 0;
  }

  .page-header {
    padding: 20px 16px 12px;
    padding-top: 64px;
  }

  .container {
    padding: 0 16px 24px;
  }

  .col-3,
  .col-4,
  .col-6,
  .col-8 {
    grid-column: span 12;
  }

  .grid {
    gap: 12px;
  }

  .card .head {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .inline {
    flex-wrap: wrap;
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
  }

  .sidebar.open~.sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }
}

/* ── Pulse animation for live dot ─────────────────────────── */
@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: .5;
  }
}

.pulse {
  animation: pulse 2s ease-in-out infinite;
}

/* ── Skeleton shimmer for loading ─────────────────────────── */
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }

  100% {
    background-position: 200% 0;
  }
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-surface) 25%, var(--bg-elevated) 50%, var(--bg-surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}