/* ===========================
   RESET & BASE STYLES
   =========================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Colors */
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --secondary: #06b6d4;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --dark: #1f2937;
  --light: #f9fafb;
  --gray: #6b7280;
  --white: #ffffff;

  /* Spacing */
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2rem;
  --spacing-xl: 3rem;

  /* Border radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  color: var(--dark);
  background-color: var(--light);
  margin: 0;
  display: flex;
  min-height: 100vh;
}

body.has-sidebar {
  background-color: #f3f4f6;
}

/* ===========================
   SIDEBAR
   =========================== */
.sidebar {
  width: 260px;
  background: var(--white);
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 1000;
}

.sidebar-header {
  padding: var(--spacing-md);
  border-bottom: 1px solid #f3f4f6;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
}

.logo-icon {
  font-size: 1.5rem;
  background: var(--primary);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: white;
}

.logo-text {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--dark);
}

.sidebar-nav {
  flex: 1;
  padding: var(--spacing-sm) 0;
  overflow-y: auto;
}

.sidebar-nav ul {
  list-style: none;
}

.sidebar-nav li {
  padding: 2px var(--spacing-sm);
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm);
  text-decoration: none;
  color: var(--gray);
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.95rem;
  transition: all 0.2s;
}

.sidebar-nav li.active a,
.sidebar-nav a:hover {
  background: #eff6ff;
  color: var(--primary);
}

.sidebar-footer {
  padding: 1.5rem 1rem;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.user-avatar img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid #f3f4f6;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-fullname {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--dark);
  line-height: 1.2;
}

.user-role {
  font-size: 0.75rem;
  color: var(--gray);
}

.sidebar-logout {
  text-decoration: none;
  font-size: 1.2rem;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.sidebar-logout:hover {
  opacity: 1;
}

.sidebar-actions {
  width: 100%;
  margin-top: var(--spacing-sm);
}

.btn-logout {
  width: 100%;
  justify-content: center;
}

/* Sidebar Collapsible Menu */
.sidebar-submenu {
  list-style: none;
  padding-left: 1.5rem;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
  background: rgba(0, 0, 0, 0.02);
}

.sidebar-item-has-children.is-expanded .sidebar-submenu {
  max-height: 200px;
  padding-bottom: var(--spacing-xs);
}

.sidebar-link-expand {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.expand-icon {
  font-size: 0.7rem;
  transition: transform 0.3s;
  margin-left: auto;
}

.is-expanded .expand-icon {
  transform: rotate(90deg);
}

.sidebar-submenu .nav-icon {
  font-size: 1rem;
}

.sidebar-submenu a {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

.btn-logout:hover {
  background: #fee2e2;
  color: #7f1d1d;
  transform: translateY(-1px);
}

.logout-icon {
  font-size: 1.1rem;
}

/* ===========================
   MAIN CONTENT & LAYOUT
   =========================== */
.main-content {
  flex: 1;
  margin-left: 260px;
  /* Width of sidebar */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.content-wrapper {
  padding: var(--spacing-lg);
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

.container {
  padding: 0;
  min-height: auto;
}

/* ===========================
   DASHBOARD
   =========================== */
.dashboard h1 {
  font-size: 2rem;
  margin-bottom: var(--spacing-md);
  color: var(--dark);
}

.welcome {
  margin-bottom: var(--spacing-lg);
  font-size: 1.1rem;
  color: var(--gray);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-xl);
}

.stat-card {
  background: var(--white);
  padding: var(--spacing-md);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  transition: transform 0.3s, box-shadow 0.3s;
}

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

.stat-icon {
  font-size: 2.5rem;
}

.stat-info h3 {
  font-size: 0.9rem;
  color: var(--gray);
  font-weight: 500;
  margin-bottom: var(--spacing-xs);
}

.stat-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}

/* ===========================
   QUICK ACTIONS
   =========================== */
.quick-actions {
  margin-bottom: var(--spacing-xl);
}

.quick-actions h2 {
  font-size: 1.5rem;
  margin-bottom: var(--spacing-md);
  color: var(--dark);
}

.action-buttons {
  display: flex;
  gap: var(--spacing-md);
  flex-wrap: wrap;
}

/* ===========================
   BUTTONS
   =========================== */
.btn {
  display: inline-block;
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-md);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.3s;
  border: none;
  cursor: pointer;
  font-size: 1rem;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--secondary);
  color: var(--white);
}

.btn-secondary:hover {
  background: #0891b2;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* ===========================
   RECENT SECTION
   =========================== */
.recent-section {
  background: var(--white);
  padding: var(--spacing-lg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.recent-section h2 {
  font-size: 1.5rem;
  margin-bottom: var(--spacing-md);
  color: var(--dark);
}

.placeholder-text {
  color: var(--gray);
  font-style: italic;
}

/* ===========================
   ERROR PAGE
   =========================== */
.error-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.error-content {
  text-align: center;
  max-width: 600px;
}

.error-code {
  font-size: 6rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: var(--spacing-sm);
}

.error-title {
  font-size: 2rem;
  margin-bottom: var(--spacing-md);
  color: var(--dark);
}

.error-message {
  font-size: 1.1rem;
  color: var(--gray);
  margin-bottom: var(--spacing-lg);
}

.error-details {
  margin: var(--spacing-lg) 0;
  text-align: left;
}

.error-details pre {
  background: var(--light);
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-size: 0.85rem;
}

/* ===========================
   FOOTER
   =========================== */
.footer {
  background: var(--white);
  border-top: 1px solid #e5e7eb;
  padding: var(--spacing-lg) 0;
  margin-top: auto;
}

.footer-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--spacing-md);
  text-align: center;
  color: var(--gray);
}

/* ===========================
   RESPONSIVE
   =========================== */
@media (max-width: 768px) {
  .nav-container {
    flex-direction: column;
    gap: var(--spacing-sm);
  }

  .nav-menu {
    flex-direction: column;
    gap: var(--spacing-xs);
    text-align: center;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .action-buttons {
    flex-direction: column;
  }

  .btn {
    width: 100%;
    text-align: center;
  }

  .error-code {
    font-size: 4rem;
  }
}