/* ==========================================================================
   1. VARIABLES & RESET
   ========================================================================== */
:root {
  --primary: #1e293b;       /* Slate 800 - Sidebar/Text */
  --accent: #e67e22;        /* Kopi/Industrial Orange */
  --accent-light: rgba(230, 126, 34, 0.1);
  --bg-body: #f1f5f9;       /* Slate 100 - Background */
  --bg-card: #ffffff;
  --text-main: #334155;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  
  /* Status Colors */
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;

  --radius: 12px;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --sidebar-width: 260px;
  --sidebar-mini: 80px;
  --navbar-height: 64px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', 'Plus Jakarta Sans', sans-serif;
}

body {
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  overflow-x: hidden;
}

/* ==========================================================================
   2. LAYOUT STRUCTURE (MODIFIED FOR SPA)
   ========================================================================== */
#app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar Styling */
#sidebar {
  width: var(--sidebar-width);
  background: var(--primary);
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 1000;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  color: white;
  overflow-y: auto;
}

#sidebar.mini {
  width: var(--sidebar-mini);
}

#main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

#sidebar.mini ~ #main-content {
  margin-left: var(--sidebar-mini);
}

#navbar {
  height: var(--navbar-height);
  background: white;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 900;
}

#app {
  padding: 24px;
  flex: 1;
  transition: opacity 0.2s ease;
}

.page-loading {
  opacity: 0.4;
  pointer-events: none;
}

/* ==========================================================================
   3. SIDEBAR MENU UTILITIES
   ========================================================================== */
.nav-link {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  color: #94a3b8;
  text-decoration: none;
  gap: 12px;
  transition: 0.2s;
  border-left: 4px solid transparent;
}

.nav-link:hover, .nav-link.active {
  background: rgba(255, 255, 255, 0.05);
  color: white;
}

.nav-link.active {
  border-left-color: var(--accent);
  color: var(--accent);
}

#sidebar.mini .menu-text {
  display: none;
}

#sidebar.mini .nav-link {
  justify-content: center;
  padding: 15px 0;
  border-left: none;
}

/* ==========================================================================
   4. COMPONENTS: CARDS & TABLES
   ========================================================================== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.table-wrapper {
  overflow-x: auto;
  width: 100%;
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.table th {
  background: #f8fafc;
  padding: 12px 16px;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--border-color);
}

.table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
}

.table tr:hover {
  background: #f1f5f9;
}

/* ==========================================================================
   5. FORMS & INPUTS
   ========================================================================== */
.form-group {
  margin-bottom: 1rem;
}

.label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-main);
}

.input, .select, .textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.95rem;
  transition: all 0.2s;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

/* ==========================================================================
   6. BUTTONS & BADGES
   ========================================================================== */
.btn {
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: 0.2s;
  font-size: 0.9rem;
}

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }

.badge {
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }

/* ==========================================================================
   7. MODAL SYSTEM
   ========================================================================== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  justify-content: center;
  align-items: flex-start;
  z-index: 2000;
  padding: 40px 20px;
  overflow-y: auto;
}

.modal.show { display: flex; }

.modal-content {
  background: white;
  border-radius: var(--radius);
  width: 100%;
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1);
  animation: modalIn 0.3s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-lg { max-width: 900px; }
.modal-md { max-width: 550px; }

/* ==========================================================================
   8. RESPONSIVE & MOBILE OVERLAY
   ========================================================================== */
#sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 999;
  display: none;
}

#sidebar-overlay.show { display: block; }

@media (max-width: 768px) {
  #sidebar {
    left: -100%; /* Sembunyi ke kiri */
  }
  
  #sidebar.show {
    left: 0;
  }
  
  #main-content {
    margin-left: 0 !important;
  }
  
  .form-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================
   9. PRINT STYLES
   ========================================================== */
@media print {
  .no-print, #sidebar, #navbar, .btn, #sidebar-overlay { display: none !important; }
  #main-content { margin: 0 !important; }
  body { background: white; }
  .card { border: none; box-shadow: none; padding: 0; }
}
