/* ================================================================
   WIHASO CPMS — Main Stylesheet (Modern Light Theme)
   ================================================================ */

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f8fafc;
  color: #334155;
  min-height: 100vh;
  line-height: 1.6;
}

/* ---------- CSS Variables ---------- */
:root {
  --sidebar-w: 260px;
  --topbar-h: 70px;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --bg-main: #ffffff;
  /* Changed from #f8fafc to white */
  --bg-card: #ffffff;
  --border: #f1f5f9;
  /* Lighter border */
  --text-main: #0f172a;
  /* Slightly darker for better contrast on white */
  --text-muted: #64748b;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --purple: #8b5cf6;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
  --transition: 0.2s ease-in-out;
}

/* ---------- App Layout ---------- */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition);
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  background: #ffffff;
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
  box-shadow: var(--shadow-sm);
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.sidebar-nav ul {
  list-style: none;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  transition: all var(--transition);
  font-size: 0.925rem;
  font-weight: 500;
}

.nav-link:hover {
  background: var(--bg-main);
  color: var(--text-main);
}

.nav-link.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.nav-header {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 20px 16px 8px;
  font-weight: 700;
}

/* ---------- Topbar ---------- */
.top-bar {
  height: var(--topbar-h);
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.25rem;
  color: var(--text-muted);
  padding: 8px;
  border-radius: 50%;
  transition: background var(--transition);
}

.btn-icon:hover {
  background: var(--bg-main);
  color: var(--text-main);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-profile span {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-main);
}

.logout-link {
  font-size: 0.8rem;
  color: var(--danger);
  text-decoration: none;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  background: #fef2f2;
}

.logout-link:hover {
  background: #fee2e2;
}

/* ---------- Page Content ---------- */
.page-content {
  padding: 32px;
  flex: 1;
}

.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

.page-header p {
  color: var(--text-muted);
  margin-top: 4px;
}

/* ---------- Stats Cards ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.stats-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
}

.stats-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.stats-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.bg-blue {
  background: #eff6ff;
  color: #2563eb;
}

.bg-green {
  background: #ecfdf5;
  color: #10b981;
}

.bg-yellow {
  background: #fffbeb;
  color: #f59e0b;
}

.bg-purple {
  background: #f5f3ff;
  color: #8b5cf6;
}

.stats-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}

.stats-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
}

/* ---------- Components ---------- */
.card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

/* ---------- Tables ---------- */
.table-responsive {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  background: #f8fafc;
  padding: 16px 24px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--text-main);
  vertical-align: middle;
}

.table tbody tr:hover {
  background: #f8fafc;
}

.table tr:last-child td {
  border-bottom: none;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success {
  background: #dcfce7;
  color: #15803d;
}

.badge-warning {
  background: #fef9c3;
  color: #a16207;
}

.badge-danger {
  background: #fee2e2;
  color: #b91c1c;
}

.badge-info {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge-secondary {
  background: #f1f5f9;
  color: #475569;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  border: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn-outline {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text-main);
}

.btn-outline:hover {
  background: var(--bg-main);
  border-color: #cbd5e0;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-danger {
  background: #fee2e2;
  color: #b91c1c;
}

.btn-danger:hover {
  background: #fecaca;
}

/* ---------- Forms ---------- */
.form-group {
  margin-bottom: 24px;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-main);
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  transition: all var(--transition);
  outline: none;
  background: #fff;
  color: var(--text-main);
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

/* ---------- Login Page ---------- */
.login-page {
  background: #f8fafc;
  /* Brighter, clean background */
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  margin: 0;
  padding: 24px;
}

.login-wrapper {
  width: 100%;
  max-width: 440px;
  padding: 24px;
}

.login-box {
  background: #ffffff;
  padding: 40px;
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
  width: 100%;
}

.login-header {
  text-align: center;
  margin-bottom: 40px;
}

.login-header h1 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -1px;
}

.login-header p {
  color: var(--text-muted);
  margin-top: 8px;
  font-size: 0.95rem;
}

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 24px;
}

.alert-danger {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fee2e2;
}

.alert-success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #d1fae5;
}

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  :root {
    --sidebar-w: 0px;
  }

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    width: 260px;
  }

  .main-content {
    margin-left: 0;
  }

  #sidebarOverlay.show {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 99;
  }
}