/* ============================================================
   HeckinSmartCard — Main CSS
   Professional Student Card Management Platform
   ============================================================ */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --sidebar-bg: #0f172a;
  --sidebar-width: 260px;
  --sidebar-collapsed: 72px;
  --topbar-h: 64px;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --bg-body: #f1f5f9;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: all .2s cubic-bezier(.4,0,.2,1);
}

[data-bs-theme="dark"] {
  --sidebar-bg: #020617;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --bg-body: #0f172a;
  --bg-card: #1e293b;
  --border: #334155;
  --primary-light: #1e3a8a20;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  transition: var(--transition);
  overflow-x: hidden;
}

/* ─── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: width .3s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .user-info,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-section-title { display: none; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  min-height: var(--topbar-h);
}

.brand-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.brand-title {
  color: white;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -.025em;
  display: block;
}

.brand-sub {
  color: rgba(255,255,255,.45);
  font-size: .68rem;
  letter-spacing: .05em;
  text-transform: uppercase;
  display: block;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.user-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,.2);
  flex-shrink: 0;
}

.user-avatar-placeholder {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,.6);
  flex-shrink: 0;
}

.user-name {
  color: white;
  font-size: .85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.15) transparent;
}

.nav-section-title {
  color: rgba(255,255,255,.35);
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: 12px 20px 4px;
  white-space: nowrap;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  border-radius: 8px;
  margin: 1px 10px;
  font-size: .875rem;
  transition: var(--transition);
  white-space: nowrap;
}

.nav-item:hover {
  background: rgba(255,255,255,.08);
  color: white;
}

.nav-item.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(37,99,235,.4);
}

.nav-item i { width: 20px; text-align: center; flex-shrink: 0; font-size: 1rem; }

/* ─── Main Content ──────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left .3s cubic-bezier(.4,0,.2,1);
  display: flex;
  flex-direction: column;
}

.main-content.expanded { margin-left: var(--sidebar-collapsed); }

/* ─── Topbar ────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  box-shadow: var(--shadow);
}

.topbar-title {
  flex: 1;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.btn-icon {
  width: 38px; height: 38px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}
.btn-icon:hover { background: var(--bg-body); color: var(--text-primary); }

/* ─── Breadcrumb ────────────────────────────────────────────── */
.breadcrumb-wrapper {
  padding: 14px 24px 0;
}

.breadcrumb {
  margin: 0;
  font-size: .82rem;
}

/* ─── Page Content ──────────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: 24px;
}

/* ─── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: var(--transition);
}

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

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: 18px 20px;
  font-weight: 600;
}

/* ─── Stat Cards ────────────────────────────────────────────── */
.stat-card {
  border-radius: var(--radius);
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 20px;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.stat-icon {
  width: 56px; height: 56px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.stat-info .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
}

.stat-info .stat-label {
  font-size: .8rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ─── Page Header ───────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
}

.page-header-sub {
  font-size: .85rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ─── Filters Bar ───────────────────────────────────────────── */
.filter-bar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

/* ─── Table ─────────────────────────────────────────────────── */
.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.table-responsive { border-radius: var(--radius); }

.table thead th {
  background: var(--bg-body);
  border-color: var(--border);
  font-weight: 600;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-secondary);
  padding: 12px 16px;
  white-space: nowrap;
}

.table tbody td {
  padding: 12px 16px;
  vertical-align: middle;
  border-color: var(--border);
  font-size: .875rem;
}

.table tbody tr:hover { background: var(--primary-light); }

/* ─── Glassmorphism panel ────────────────────────────────────── */
.glass-card {
  background: rgba(255,255,255,.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,.35);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

[data-bs-theme="dark"] .glass-card {
  background: rgba(30,41,59,.55);
  border-color: rgba(255,255,255,.1);
}

/* ─── Form styles ───────────────────────────────────────────── */
.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}

.form-label {
  font-weight: 500;
  font-size: .875rem;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-control, .form-select {
  border-radius: var(--radius-sm);
  border-color: var(--border);
  font-size: .9rem;
  transition: var(--transition);
  background: var(--bg-card);
  color: var(--text-primary);
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

/* ─── Buttons ───────────────────────────────────────────────── */
.btn {
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: .875rem;
  transition: var(--transition);
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37,99,235,.35);
}

.btn-outline-secondary:hover { transform: translateY(-1px); }

/* ─── Student Card Preview ───────────────────────────────────── */
.card-cr80 {
  width: 340px;
  height: 215px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  position: relative;
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 50%, #0ea5e9 100%);
}

/* ─── Photo upload drop zone ─────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}

.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}

.drop-zone i { font-size: 2.5rem; color: var(--text-secondary); margin-bottom: 12px; }

/* ─── Badge enhancements ─────────────────────────────────────── */
.badge { font-weight: 500; letter-spacing: .02em; }

/* ─── Activity feed ──────────────────────────────────────────── */
.activity-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: .85rem;
}

.activity-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: .85rem;
}

/* ─── Loader overlay ─────────────────────────────────────────── */
.loader-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  display: none;
}

/* ─── Animations ─────────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-in-up { animation: fadeInUp .35s ease forwards; }

/* ─── Auth pages ─────────────────────────────────────────────── */
.auth-wrapper {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #1e40af 100%);
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border-radius: 20px;
  padding: 40px;
  box-shadow: 0 25px 50px -12px rgb(0 0 0 / .4);
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo-icon {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  border-radius: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.8rem;
  color: white;
  box-shadow: 0 8px 24px rgba(37,99,235,.4);
  margin-bottom: 16px;
}

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width) !important;
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; }
  .page-content { padding: 16px; }
}

/* ─── Select2 overrides ──────────────────────────────────────── */
.select2-container--bootstrap-5 .select2-selection {
  border-radius: var(--radius-sm) !important;
  border-color: var(--border) !important;
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
}

/* ─── DataTables overrides ───────────────────────────────────── */
div.dataTables_wrapper div.dataTables_filter input,
div.dataTables_wrapper div.dataTables_length select {
  border-radius: var(--radius-sm);
}

/* ─── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }
