/* ════════════════════════════════════════════════════════════════════
   EIDCA CMS – Main Stylesheet
   Dark sidebar + Light content + Violet/Blue brand
═══════════════════════════════════════════════════════════════════ */

/* ── Tokens ─────────────────────────────────────────────────────── */
:root {
  --sidebar-bg:      #0f172a;
  --sidebar-border:  #1e293b;
  --sidebar-w:       260px;

  --accent:          #7c3aed;
  --accent-2:        #4f46e5;
  --accent-light:    rgba(124,58,237,.12);
  --accent-glow:     rgba(124,58,237,.3);

  --teal:            #0d9488;
  --teal-light:      rgba(13,148,136,.12);
  --blue:            #2563eb;
  --blue-light:      rgba(37,99,235,.12);
  --green:           #16a34a;
  --green-light:     rgba(22,163,74,.12);
  --warn:            #d97706;
  --warn-light:      rgba(217,119,6,.12);
  --danger:          #dc2626;
  --danger-light:    rgba(220,38,38,.12);
  --gray-light:      rgba(100,116,139,.12);

  --bg:              #f1f5f9;
  --surface:         #ffffff;
  --surface-alt:     #f8fafc;
  --border:          #e2e8f0;
  --border-strong:   #cbd5e1;
  --text:            #0f172a;
  --text-2:          #334155;
  --text-3:          #64748b;
  --text-inv:        #ffffff;

  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.12);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  display: flex;
}

/* ── Sidebar ──────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: transform .25s ease;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 1.5rem 1.25rem 1.25rem;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.sidebar-logo {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px var(--accent-glow);
}
.sidebar-brand { font-size: 15px; font-weight: 800; color: #f1f5f9; letter-spacing: -.3px; }
.sidebar-sub   { font-size: 11px; color: #475569; margin-top: 1px; font-weight: 500; }

.sidebar-nav { flex: 1; padding: .75rem 0; }

.nav-section-label {
  font-size: 10.5px;
  font-weight: 700;
  color: #334155;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 1.25rem 1.25rem .4rem;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 1.25rem;
  font-size: 13.5px;
  font-weight: 500;
  color: #94a3b8;
  text-decoration: none;
  border-radius: 0;
  transition: all .15s;
  position: relative;
  cursor: pointer;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item .nav-ext { font-size: 10px; margin-left: auto; opacity: .5; }
.nav-item:hover {
  background: rgba(255,255,255,.05);
  color: #e2e8f0;
}
.nav-item.active {
  background: var(--accent-light);
  color: #a78bfa;
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.user-card { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.user-avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: #475569; margin-top: 1px; }
.btn-logout {
  width: 32px; height: 32px;
  background: rgba(220,38,38,.12);
  border: 1px solid rgba(220,38,38,.2);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: #f87171;
  cursor: pointer; text-decoration: none; flex-shrink: 0;
  transition: all .15s;
}
.btn-logout:hover { background: rgba(220,38,38,.2); }

/* ── Overlay (mobile) ─────────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 199;
}

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

/* ── Topbar ────────────────────────────────────────────────────────── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky; top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.hamburger {
  display: none;
  flex-direction: column; gap: 5px;
  background: none; border: none; cursor: pointer; padding: 4px;
}
.hamburger span {
  display: block; width: 20px; height: 2px;
  background: var(--text-3); border-radius: 2px; transition: all .2s;
}
.topbar-title {
  font-size: 16px; font-weight: 700;
  color: var(--text); flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-user {
  font-size: 13px; font-weight: 600; color: var(--text-3);
  padding: 5px 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 20px;
}

/* ── Flash message ────────────────────────────────────────────────── */
.flash {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 2rem;
  font-size: 13.5px; font-weight: 500;
  gap: 12px;
}
.flash-success { background: #f0fdf4; color: #15803d; border-bottom: 1px solid #bbf7d0; }
.flash-error   { background: #fef2f2; color: #b91c1c; border-bottom: 1px solid #fecaca; }
.flash-warning { background: #fffbeb; color: #92400e; border-bottom: 1px solid #fde68a; }
.flash-close   { background: none; border: none; font-size: 18px; cursor: pointer; color: inherit; opacity: .7; padding: 0 4px; }
.flash-close:hover { opacity: 1; }

/* ── Content area ──────────────────────────────────────────────────── */
.content {
  flex: 1;
  padding: 2rem;
  max-width: 1200px;
  width: 100%;
}

/* ── Page header ──────────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 2rem; gap: 1rem; flex-wrap: wrap;
}
.page-header-left h1 {
  font-size: 24px; font-weight: 800;
  color: var(--text); letter-spacing: -.5px;
}
.page-header-left p {
  font-size: 14px; color: var(--text-3); margin-top: 4px; line-height: 1.5;
}

/* ── Stat cards ────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 1.5rem;
  display: flex; flex-direction: column; gap: 10px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s, transform .2s;
  position: relative; overflow: hidden;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
}
.stat-card.violet::before { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.stat-card.blue::before   { background: linear-gradient(90deg, #2563eb, #0ea5e9); }
.stat-card.teal::before   { background: linear-gradient(90deg, #0d9488, #10b981); }
.stat-card.warn::before   { background: linear-gradient(90deg, #d97706, #f59e0b); }
.stat-icon {
  width: 40px; height: 40px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
}
.stat-icon.violet { background: var(--accent-light); color: var(--accent); }
.stat-icon.blue   { background: var(--blue-light);   color: var(--blue); }
.stat-icon.teal   { background: var(--teal-light);   color: var(--teal); }
.stat-icon.warn   { background: var(--warn-light);   color: var(--warn); }
.stat-icon svg { width: 20px; height: 20px; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--text); letter-spacing: -1px; line-height: 1; }
.stat-label { font-size: 12.5px; color: var(--text-3); font-weight: 500; }
.stat-trend { font-size: 11.5px; color: var(--green); font-weight: 600; margin-top: 2px; }

/* ── Card ──────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: var(--surface-alt);
}
.card-header h2 {
  font-size: 14px; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.card-header h2 svg { width: 16px; height: 16px; color: var(--accent); }
.card-body { padding: 1.5rem; }

/* ── Table ──────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  padding: 10px 12px;
  text-align: left;
  font-size: 11.5px; font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase; letter-spacing: .06em;
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
  background: var(--surface-alt);
}
tbody td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-alt); }
.td-mono { font-family: 'SF Mono','Fira Code',monospace; font-size: 12.5px; }

/* ── Badges ──────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.badge-violet { background: var(--accent-light); color: var(--accent); }
.badge-blue   { background: var(--blue-light);   color: var(--blue); }
.badge-teal   { background: var(--teal-light);   color: var(--teal); }
.badge-green  { background: var(--green-light);  color: var(--green); }
.badge-warn   { background: var(--warn-light);   color: var(--warn); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-gray   { background: var(--gray-light);   color: var(--text-3); }

/* ── Form ────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--text-2); margin-bottom: 6px;
}
.form-group label .req { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%; padding: 10px 13px; font-size: 14px;
  font-family: 'Inter', sans-serif;
  border: 1.5px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  appearance: none; -webkit-appearance: none;
}
.form-control:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.form-control.error { border-color: var(--danger); }
.form-hint { font-size: 11.5px; color: var(--text-3); margin-top: 5px; line-height: 1.5; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* Input with copy button */
.input-group { display: flex; gap: 0; }
.input-group .form-control { border-radius: var(--r-md) 0 0 var(--r-md); }
.input-group .btn-copy {
  padding: 0 14px; background: var(--surface-alt);
  border: 1.5px solid var(--border); border-left: none;
  border-radius: 0 var(--r-md) var(--r-md) 0;
  cursor: pointer; font-size: 12px; font-weight: 600;
  color: var(--text-3); white-space: nowrap; transition: all .15s;
}
.input-group .btn-copy:hover { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 20px; font-size: 14px; font-weight: 600;
  font-family: 'Inter', sans-serif;
  border-radius: var(--r-md); cursor: pointer;
  border: 1.5px solid transparent;
  transition: all .15s ease; letter-spacing: -.1px;
  text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 15px; height: 15px; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #fff; border-color: var(--accent);
  box-shadow: 0 2px 8px var(--accent-glow);
}
.btn-primary:hover { opacity: .9; box-shadow: 0 4px 16px var(--accent-glow); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-secondary {
  background: var(--surface); color: var(--text-2); border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface-alt); border-color: var(--border-strong); }
.btn-danger {
  background: var(--danger-light); color: var(--danger); border-color: rgba(220,38,38,.3);
}
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-xs { padding: 4px 10px; font-size: 12px; }
.btn-row { display: flex; gap: 10px; margin-top: 1.5rem; flex-wrap: wrap; }

/* ── Spinner ────────────────────────────────────────────────────────── */
.spin {
  display: inline-block; width: 16px; height: 16px;
  border: 2.5px solid rgba(255,255,255,.3);
  border-top-color: #fff; border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }

/* ── Pagination ──────────────────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; align-items: center; margin-top: 1.25rem; flex-wrap: wrap; }
.page-link {
  padding: 6px 12px; font-size: 13px; font-weight: 500;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  color: var(--text-2); text-decoration: none; background: var(--surface);
  transition: all .15s;
}
.page-link:hover { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }
.page-link.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-link.disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }

/* ── Filter bar ──────────────────────────────────────────────────────── */
.filter-bar {
  display: flex; gap: .75rem; flex-wrap: wrap;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
}
.filter-bar .form-control { width: auto; flex: 1; min-width: 140px; padding: 7px 11px; font-size: 13px; }
.filter-bar .btn { padding: 7px 16px; font-size: 13px; }

/* ── Login/Register page ─────────────────────────────────────────────── */
body.auth-page {
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.auth-box {
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 24px;
  padding: 2.5rem;
  width: 100%; max-width: 420px;
  backdrop-filter: blur(20px);
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.auth-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 2rem; }
.auth-logo-icon {
  width: 48px; height: 48px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px var(--accent-glow);
}
.auth-brand { font-size: 22px; font-weight: 800; color: #f1f5f9; letter-spacing: -.5px; }
.auth-sub   { font-size: 13px; color: #475569; margin-top: 2px; }
.auth-title { font-size: 20px; font-weight: 700; color: #f1f5f9; margin-bottom: .4rem; }
.auth-desc  { font-size: 13.5px; color: #64748b; margin-bottom: 1.75rem; line-height: 1.5; }

.auth-form .form-group label { color: #94a3b8; }
.auth-form .form-control {
  background: rgba(255,255,255,.05);
  border-color: rgba(255,255,255,.1);
  color: #f1f5f9;
}
.auth-form .form-control::placeholder { color: #475569; }
.auth-form .form-control:focus {
  border-color: var(--accent);
  background: rgba(124,58,237,.08);
  box-shadow: 0 0 0 3px rgba(124,58,237,.2);
}
.auth-form .btn-primary { width: 100%; padding: 12px; font-size: 15px; margin-top: .5rem; }
.auth-link { text-align: center; margin-top: 1.25rem; font-size: 13.5px; color: #64748b; }
.auth-link a { color: #a78bfa; text-decoration: none; font-weight: 600; }
.auth-link a:hover { color: var(--accent); }
.auth-error {
  background: rgba(220,38,38,.12); border: 1px solid rgba(220,38,38,.25);
  color: #fca5a5; padding: 10px 14px; border-radius: var(--r-md);
  font-size: 13px; margin-bottom: 1rem; line-height: 1.5;
}

/* ── Alert ────────────────────────────────────────────────────────────── */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px; border-radius: var(--r-md);
  font-size: 13.5px; line-height: 1.5; margin-bottom: 1rem;
}
.alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.alert-info    { background: var(--blue-light);   color: var(--blue);   border: 1px solid rgba(37,99,235,.2); }
.alert-success { background: var(--green-light);  color: var(--green);  border: 1px solid rgba(22,163,74,.2); }
.alert-warn    { background: var(--warn-light);   color: var(--warn);   border: 1px solid rgba(217,119,6,.2); }
.alert-danger  { background: var(--danger-light); color: var(--danger); border: 1px solid rgba(220,38,38,.2); }

/* ── Empty state ──────────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 3rem 1rem;
}
.empty-icon {
  width: 64px; height: 64px;
  background: var(--surface-alt); border-radius: var(--r-xl);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1rem;
}
.empty-icon svg { width: 28px; height: 28px; color: var(--text-3); }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.empty-state p  { font-size: 13.5px; color: var(--text-3); }

/* ── Quick link tiles ─────────────────────────────────────────────────── */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.tool-tile {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-xl);
  padding: 1.5rem;
  text-decoration: none;
  display: flex; flex-direction: column; gap: 12px;
  transition: all .2s; cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.tool-tile:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 20px var(--accent-glow);
  transform: translateY(-3px);
}
.tool-tile-icon {
  width: 48px; height: 48px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
}
.tool-tile-icon svg { width: 24px; height: 24px; }
.tool-tile-icon.violet { background: var(--accent-light); color: var(--accent); }
.tool-tile-icon.blue   { background: var(--blue-light);   color: var(--blue); }
.tool-tile-icon.teal   { background: var(--teal-light);   color: var(--teal); }
.tool-tile h3 { font-size: 14px; font-weight: 700; color: var(--text); }
.tool-tile p  { font-size: 12.5px; color: var(--text-3); line-height: 1.5; }
.tool-tile-arrow { font-size: 18px; color: var(--text-3); align-self: flex-end; }

/* ── Code block ─────────────────────────────────────────────────────── */
.code-block {
  background: #0f172a; color: #a5f3fc;
  border-radius: var(--r-md); padding: 1rem 1.25rem;
  font-family: 'SF Mono','Fira Code',monospace; font-size: 12.5px;
  line-height: 1.7; overflow-x: auto;
  border: 1px solid #1e293b;
}
.code-block .kw  { color: #c084fc; }
.code-block .str { color: #86efac; }
.code-block .cmt { color: #475569; font-style: italic; }
.code-block .var { color: #fbbf24; }

/* ── Password strength bar ───────────────────────────────────────────── */
.pw-strength { height: 4px; border-radius: 2px; margin-top: 6px; background: var(--border); overflow: hidden; }
.pw-strength-fill { height: 100%; border-radius: 2px; width: 0; transition: width .3s, background .3s; }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .main-wrapper { margin-left: 0; }
  .hamburger { display: flex; }
  .content { padding: 1.25rem; }
  .topbar { padding: 0 1.25rem; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .auth-box { padding: 1.75rem; }
  .stats-grid { grid-template-columns: 1fr; }
  .tool-grid { grid-template-columns: 1fr; }
}
