/* =============================================================
   ESYS — Custom Stylesheet
   Modern Admin Panel / Bootstrap 5 Base
   ============================================================= */

/* ---- CSS Variables ---- */
:root {
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 72px;
  --navbar-height: 60px;

  --color-primary: #0d6efd;
  --color-success: #198754;
  --color-warning: #ffc107;
  --color-danger: #dc3545;
  --color-info: #0dcaf0;
  --color-secondary: #6c757d;

  --sidebar-bg: #0f172a;
  --sidebar-border: rgba(255,255,255,0.06);
  --sidebar-text: #94a3b8;
  --sidebar-text-hover: #f1f5f9;
  --sidebar-active-bg: rgba(13,110,253,0.15);
  --sidebar-active-border: #0d6efd;
  --sidebar-section-color: #475569;

  --navbar-bg: #ffffff;
  --navbar-border: #e9ecef;
  --body-bg: #f1f5f9;
  --card-bg: #ffffff;
  --card-border: #e9ecef;

  --transition: all 0.22s cubic-bezier(.4,0,.2,1);
}

[data-bs-theme="dark"] {
  --sidebar-bg: #0a0f1e;
  --sidebar-border: rgba(255,255,255,0.05);
  --navbar-bg: #111827;
  --navbar-border: #1f2937;
  --body-bg: #0d1117;
  --card-bg: #161b27;
  --card-border: #1f2937;
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; }

body.esys-body {
  background-color: var(--body-bg);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.9rem;
  color: var(--bs-body-color);
  overflow-x: hidden;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.esys-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: var(--transition);
  overflow: hidden;
  border-right: 1px solid var(--sidebar-border);
}

/* Sidebar Header */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: var(--navbar-height);
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  overflow: hidden;
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: transparent;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1rem;
  flex-shrink: 0;
  padding: 2px;
  margin-right: 8px;
}

.brand-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 6px;
}

.brand-text { overflow: hidden; }

.brand-name {
  display: block;
  font-weight: 700;
  font-size: 1.05rem;
  color: #f1f5f9;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.brand-sub {
  display: block;
  font-size: 0.65rem;
  color: var(--sidebar-text);
  white-space: nowrap;
  letter-spacing: 0.3px;
}

.sidebar-toggle-btn {
  color: var(--sidebar-text);
  padding: 4px 6px;
  line-height: 1;
  border-radius: 6px;
  transition: var(--transition);
  flex-shrink: 0;
}
.sidebar-toggle-btn:hover { color: var(--sidebar-text-hover); }

/* Sidebar User */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.1);
}

.sidebar-user-info {
  overflow: hidden;
  min-width: 0;
}

.sidebar-user-name {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 0.65rem;
  background: rgba(13,110,253,0.2);
  color: #93c5fd;
  border-radius: 4px;
  padding: 1px 6px;
  font-weight: 500;
}

/* Sidebar Nav */
.sidebar-nav-wrapper {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar-nav {
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-section-title {
  padding: 12px 16px 4px;
  overflow: hidden;
}

.nav-section-title span {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--sidebar-section-color);
  white-space: nowrap;
}

.nav-item { padding: 1px 8px; }

.nav-item .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  color: var(--sidebar-text);
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.855rem;
  font-weight: 500;
  transition: var(--transition);
  white-space: nowrap;
  overflow: hidden;
  border-left: 3px solid transparent;
}

.nav-item .nav-link:hover:not(.disabled) {
  background: rgba(255,255,255,0.06);
  color: var(--sidebar-text-hover);
}

.nav-item .nav-link.active {
  background: var(--sidebar-active-bg);
  color: #60a5fa;
  border-left-color: var(--sidebar-active-border);
}

.nav-item .nav-link.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.nav-icon {
  width: 18px;
  text-align: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.nav-label { flex: 1; }

/* Sidebar Footer */
.sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-footer .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.855rem;
  font-weight: 500;
  text-decoration: none;
  transition: var(--transition);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-footer .nav-link:hover {
  background: rgba(220,53,69,0.12);
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.esys-main {
  position: relative;
  z-index: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
}

/* ============================================================
   NAVBAR
   ============================================================ */
.esys-navbar {
  height: var(--navbar-height);
  background: var(--navbar-bg);
  border-bottom: 1px solid var(--navbar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 1030;
  gap: 16px;
}

.navbar-left { display: flex; align-items: center; gap: 12px; }
.navbar-right { display: flex; align-items: center; gap: 6px; }

.navbar-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--color-primary);
}

.btn-ghost-secondary {
  background: transparent;
  border: none;
  color: var(--bs-secondary-color);
  border-radius: 8px;
  transition: var(--transition);
}
.btn-ghost-secondary:hover {
  background: var(--bs-secondary-bg);
  color: var(--bs-body-color);
}
.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.notification-dropdown { min-width: 320px; max-height: 420px; overflow-y: auto; }

/* ============================================================
   CONTENT & FOOTER
   ============================================================ */
.esys-content {
  flex: 1;
  padding: 24px;
}

.esys-footer {
  padding: 12px 24px;
  border-top: 1px solid var(--navbar-border);
  font-size: 0.78rem;
  color: var(--bs-secondary-color);
  background: var(--navbar-bg);
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title { font-size: 1.4rem; font-weight: 700; margin: 0; line-height: 1.3; }
.page-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-card {
  border-radius: 12px;
  padding: 18px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid transparent;
  transition: var(--transition);
  background: var(--card-bg);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.1); }

.stat-icon {
  width: 46px; height: 46px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0;
}
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 0.76rem; color: var(--bs-secondary-color); font-weight: 500; margin-top: 2px; }

.stat-card-primary  .stat-icon { background: rgba(13,110,253,0.12);  color: #0d6efd; }
.stat-card-success  .stat-icon { background: rgba(25,135,84,0.12);   color: #198754; }
.stat-card-warning  .stat-icon { background: rgba(255,193,7,0.12);   color: #b98900; }
.stat-card-danger   .stat-icon { background: rgba(220,53,69,0.12);   color: #dc3545; }
.stat-card-info     .stat-icon { background: rgba(13,202,240,0.12);  color: #0dcaf0; }
.stat-card-secondary .stat-icon { background: rgba(108,117,125,0.12); color: #6c757d; }

/* ============================================================
   CARDS
   ============================================================ */
.card { background: var(--card-bg); border-color: var(--card-border) !important; border-radius: 12px; }
.card-header { background: transparent; }

/* ============================================================
   FLASH MESSAGES
   ============================================================ */
.flash-container { margin-bottom: 20px; }
.flash-container .alert { border-radius: 10px; border: none; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-wrapper { display: flex; min-height: 100vh; }

.login-left {
  flex: 1;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0d6efd 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
}
.login-left-content { max-width: 460px; }

.login-brand { display: flex; align-items: center; gap: 14px; }

.login-brand-icon {
  width: 52px; height: 52px;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(8px);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.4rem;
}
.login-brand-icon-sm { width: 42px; height: 42px; font-size: 1.1rem; }

.login-brand-name { font-size: 1.6rem; font-weight: 800; color: #fff; margin: 0; }
.login-brand-sub  { font-size: 0.8rem; color: rgba(255,255,255,0.65); margin: 0; }
.login-headline   { font-size: 2rem; font-weight: 700; color: #fff; line-height: 1.3; margin-bottom: 16px; }
.login-desc       { color: rgba(255,255,255,0.7); font-size: 0.95rem; margin-bottom: 28px; }
.login-features   { display: flex; flex-direction: column; gap: 10px; }
.login-feature-item { color: rgba(255,255,255,0.85); font-size: 0.9rem; display: flex; align-items: center; }

.login-right {
  width: 480px;
  display: flex; align-items: center; justify-content: center;
  padding: 40px 32px;
  background: var(--body-bg);
}
.login-card { width: 100%; max-width: 400px; }
.login-card-header { margin-bottom: 28px; }
.login-title    { font-size: 1.6rem; font-weight: 700; margin-bottom: 4px; }
.login-subtitle { color: var(--bs-secondary-color); margin: 0; }
.login-footer   { text-align: center; }

/* ============================================================
   ERROR PAGES
   ============================================================ */
.error-page { padding: 60px 20px; }
.error-code  { line-height: 1; }

/* ============================================================
   SIDEBAR OVERLAY (mobile)
   ============================================================ */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1039;
}

/* ============================================================
   COLLAPSED SIDEBAR
   ============================================================ */
body.sidebar-collapsed .esys-sidebar { width: var(--sidebar-collapsed-width); }
body.sidebar-collapsed .esys-main    { margin-left: var(--sidebar-collapsed-width); }
body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .brand-icon,
body.sidebar-collapsed .sidebar-user-info,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .nav-section-title span,
body.sidebar-collapsed .sidebar-footer .nav-label {
  opacity: 0; width: 0; overflow: hidden;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 991.98px) {
  .esys-sidebar { transform: translateX(-100%); width: var(--sidebar-width); }
  .esys-main    { margin-left: 0; }

  body.sidebar-open .esys-sidebar     { transform: translateX(0); }
  body.sidebar-open .sidebar-overlay  { display: block; }
  body.sidebar-collapsed .esys-sidebar { transform: translateX(-100%); }
  body.sidebar-collapsed .esys-main    { margin-left: 0; }

  .login-right  { width: 100%; padding: 24px 20px; }
  .esys-content { padding: 16px; }
}

@media (max-width: 575.98px) {
  .page-title  { font-size: 1.2rem; }
  .stat-value  { font-size: 1.3rem; }
}
