/* ========================================================
   Layout : Sidebar + Topbar + Main, responsive
   ======================================================== */

/* === LOGIN === */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy-900) 0%, var(--navy-700) 100%);
  padding: var(--space-4);
}
.login-card {
  background: var(--surface);
  width: 100%;
  max-width: 420px;
  padding: var(--space-8);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.login-logo {
  text-align: center;
  margin-bottom: var(--space-6);
}
.login-logo img { width: 80px; height: 80px; object-fit: contain; }
.login-logo h1 { font-size: var(--text-xl); margin-top: var(--space-3); color: var(--navy-800); }
.login-logo small { display: block; margin-top: var(--space-1); color: var(--text-soft); font-weight: 500; }

/* === APP SHELL === */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* === SIDEBAR === */
.sidebar {
  background: var(--navy-800);
  color: var(--surface);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 50;
}
.sidebar-brand {
  padding: var(--space-5) var(--space-4);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.sidebar-brand img { width: 40px; height: 40px; object-fit: contain; background: var(--surface); border-radius: var(--radius); padding: 4px; }
.sidebar-brand .brand-text { color: var(--surface); font-weight: 700; font-size: var(--text-md); line-height: 1.1; }
.sidebar-brand .brand-text small { display: block; color: var(--gold-300); font-weight: 500; font-size: var(--text-xs); margin-top: 2px; }

.sidebar-nav {
  flex: 1;
  padding: var(--space-3) var(--space-2);
  overflow-y: auto;
}
.nav-group { margin-bottom: var(--space-4); }
.nav-group-title {
  font-size: var(--text-xs);
  text-transform: uppercase;
  color: rgba(255,255,255,0.5);
  padding: var(--space-2) var(--space-3);
  letter-spacing: 0.5px;
  font-weight: 600;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  margin: 2px 0;
  color: rgba(255,255,255,0.85);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: var(--text-sm);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--navy-700); color: var(--surface); text-decoration: none; }
.nav-item.active { background: var(--gold-500); color: var(--navy-900); font-weight: 600; }
.nav-item .icon { width: 18px; flex-shrink: 0; }
.nav-item .badge { margin-left: auto; background: var(--danger); color: var(--surface); font-size: var(--text-xs); padding: 1px 6px; border-radius: var(--radius-full); font-weight: 600; }

.sidebar-footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
  background: var(--navy-900);
  position: sticky;
  bottom: 0;
  z-index: 10;
  flex-shrink: 0;
}
.sidebar-footer .avatar {
  width: 36px; height: 36px; border-radius: var(--radius-full);
  background: var(--gold-500); color: var(--navy-900);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: var(--text-sm);
  flex-shrink: 0;
}
.sidebar-footer .user-info { line-height: 1.2; flex: 1; min-width: 0; overflow: hidden; }
.sidebar-footer .user-info strong { color: var(--surface); font-size: var(--text-sm); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer .user-info small { color: var(--gold-300); font-size: var(--text-xs); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer .logout-btn {
  background: rgba(220, 38, 38, 0.15);
  border: 1px solid rgba(220, 38, 38, 0.5);
  color: #fca5a5;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 700;
  transition: all .15s;
  flex-shrink: 0;
}
.sidebar-footer .logout-btn:hover {
  background: #dc2626;
  color: #fff;
  border-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.25);
}

/* === MAIN CONTENT === */
.main {
  background: var(--bg);
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 var(--space-6);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar-left { display: flex; align-items: center; gap: var(--space-4); }
.topbar-title { font-size: var(--text-lg); font-weight: 700; color: var(--navy-800); }
.breadcrumb { color: var(--text-soft); font-size: var(--text-sm); }
.topbar-right { display: flex; align-items: center; gap: var(--space-3); }

.page-content {
  flex: 1;
  padding: var(--space-6);
  max-width: 100%;
  overflow-x: auto;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}
.page-header h1 { color: var(--navy-800); }
.page-header .page-actions { display: flex; gap: var(--space-2); }

/* === GRIDS === */
.grid { display: grid; gap: var(--space-4); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* === RESPONSIVE === */
@media (max-width: 1280px) {
  .grid-4 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 1024px) {
  .app-shell { grid-template-columns: 220px 1fr; }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .page-content { padding: var(--space-4); }
}
@media (max-width: 768px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: -100%; width: 100%; height: 100vh;
    transition: left 0.3s;
  }
  .sidebar.open { left: 0; }
  .sidebar-toggle { display: inline-flex !important; }
  .topbar { padding: 0 var(--space-4); }
  .page-content { padding: var(--space-4); }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: stretch; }
  .page-header .page-actions { width: 100%; flex-wrap: wrap; }
  .page-header .page-actions .btn { flex: 1; min-width: 120px; }
}
.sidebar-toggle {
  display: none;
  background: none; border: 0;
  color: var(--navy-800);
  font-size: 22px; cursor: pointer;
  padding: var(--space-2);
}
