:root {
    --primary: #4f46e5;
    --primary-light: #e0e7ff;
    --primary-dark: #3730a3;
    --secondary: #10b981;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --info: #0ea5e9;
    --bg-dark: #0f172a;
    --bg-darker: #020617;
    --panel-bg: rgba(30, 41, 59, 0.7);
    --panel-border: rgba(255, 255, 255, 0.08);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --font-family: 'Inter', sans-serif;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-darker);
    color: var(--text-main);
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(79, 70, 229, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 85% 30%, rgba(16, 185, 129, 0.1) 0%, transparent 50%);
    background-attachment: fixed;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Typography & Utilities */
h1, h2, h3, h4 { font-weight: 600; margin-bottom: 0.5rem; }
p { margin-bottom: 1rem; color: var(--text-muted); }
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--secondary) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger { color: var(--danger) !important; }
.text-info { color: var(--info) !important; }
.text-dark { color: #000 !important; }
.text-muted { color: var(--text-muted) !important; }

.bg-primary-light { background-color: rgba(79, 70, 229, 0.15); }
.bg-warning-light { background-color: rgba(245, 158, 11, 0.15); }

.w-100 { width: 100%; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1.5rem; }
.p-4 { padding: 1.5rem; }
.d-flex { display: flex; }
.justify-content-between { justify-content: space-between; }
.align-items-center { align-items: center; }
.hidden { display: none !important; }

/* Glassmorphism Panels */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

/* Gradients */
.gradient-1 { background: linear-gradient(135deg, rgba(79, 70, 229, 0.2), rgba(30, 41, 59, 0.8)); }
.gradient-2 { background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(30, 41, 59, 0.8)); }
.gradient-3 { background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(30, 41, 59, 0.8)); }
.gradient-4 { background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(30, 41, 59, 0.8)); }
.gradient-dark { background: linear-gradient(135deg, #1e293b, #0f172a); border: 1px solid #334155; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    font-family: inherit;
    font-size: 0.95rem;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--secondary); color: white; }
.btn-warning { background: var(--warning); color: #020617; }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 0.5rem 1rem; font-size: 0.85rem; }
.btn-icon-only { padding: 0.5rem; border-radius: 6px; }
.btn-outline-primary { background: transparent; border: 1px solid var(--primary); color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); color: white; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.5rem; font-size: 0.9rem; color: var(--text-muted); }
input {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    font-family: inherit;
    transition: var(--transition);
}
input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2); }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1); cursor: pointer; }

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

/* Login Screen */
.login-wrapper {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.login-box {
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
    animation: fadeIn 0.5s ease-out;
}
.login-header { text-align: center; margin-bottom: 2rem; }
.login-header .logo-icon { font-size: 3rem; color: var(--warning); margin-bottom: 1rem; filter: drop-shadow(0 0 10px rgba(245,158,11,0.5)); }
.input-group { position: relative; margin-bottom: 1.5rem; }
.input-group i { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.input-group input { padding-left: 2.75rem; }
.login-footer { margin-top: 1.5rem; text-align: center; color: var(--text-muted); }

/* App Layout */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}
.sidebar {
    width: 260px;
    height: 100vh;
    position: fixed;
    border-radius: 0;
    border-left: none;
    border-top: none;
    border-bottom: none;
    display: flex;
    flex-direction: column;
    z-index: 100;
}
.sidebar-header {
    padding: 2rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--panel-border);
}
.sidebar-header .logo-icon { font-size: 1.5rem; color: var(--warning); }
.sidebar-nav {
    flex: 1;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 8px;
    transition: var(--transition);
}
.nav-item:hover, .nav-item.active {
    background: rgba(79, 70, 229, 0.15);
    color: var(--primary-light);
}
.nav-item.active { border-left: 3px solid var(--primary); }
.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--panel-border);
}
.user-info { display: flex; align-items: center; gap: 1rem; }
.user-info img { width: 40px; height: 40px; border-radius: 50%; }

/* Main Content Area */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-radius: 12px;
}
.d-mobile { display: none; }
.btn-icon { background: transparent; border: none; color: white; font-size: 1.25rem; cursor: pointer; }

/* Dashboard Widgets */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
}
.stat-card {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}
.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    background: rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
}
.stat-details h3 { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 0.25rem; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: white; margin: 0; }

.chart-container { height: 350px; position: relative; }

/* Tables */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; text-align: left; }
.table th, .table td { padding: 1rem; border-bottom: 1px solid var(--panel-border); }
.table th { color: var(--text-muted); font-weight: 500; font-size: 0.9rem; }
.table tbody tr:hover { background: rgba(255,255,255,0.02); }

/* Badges */
.total-badge { padding: 0.5rem 1rem; border-radius: 20px; font-weight: 600; font-size: 0.9rem; }
.badge { padding: 0.35em 0.65em; font-size: 0.75em; border-radius: 0.25rem; }
.bg-primary { background-color: var(--primary) !important; color: white; }
.bg-warning { background-color: var(--warning) !important; color: black; }
.rounded-pill { border-radius: 50rem !important; }

/* Custom Views */
.pakan-hero { text-align: center; padding: 2rem 0; }
.huge-stock { font-size: 4rem; font-weight: 700; color: var(--warning); text-shadow: 0 0 20px rgba(245,158,11,0.3); }

.grid-2-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); gap: 1.5rem; }

.report-summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.report-card { background: rgba(0,0,0,0.2); padding: 1.5rem; border-radius: 12px; border: 1px solid var(--panel-border); text-align: center; }
.report-card small { display: block; margin-bottom: 0.5rem; color: var(--text-muted); }
.report-card strong { font-size: 1.5rem; display: block; }
.list-group { list-style: none; padding: 0; }
.list-group-item { background: rgba(0,0,0,0.2); padding: 1rem; border: 1px solid var(--panel-border); margin-bottom: -1px; }
.list-group-item:first-child { border-top-left-radius: 8px; border-top-right-radius: 8px; }
.list-group-item:last-child { border-bottom-left-radius: 8px; border-bottom-right-radius: 8px; }

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.view-section { animation: fadeIn 0.4s ease-out; }

/* Mobile Responsive */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.3s ease; }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; padding: 1rem; }
    .d-mobile { display: inline-flex; }
    .topbar { margin-bottom: 1rem; }
    .grid-2-col { grid-template-columns: 1fr; }
}

/* Print Styles for PDF / Cetak Laporan */
@media print {
    @page { margin: 1.5cm; }
    
    body, html, .app-wrapper, .main-content {
        background: white !important;
        color: black !important;
        height: auto !important;
        min-height: auto !important;
        position: static !important;
        overflow: visible !important;
        display: block !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .sidebar, .btn, button, #mobile-menu-toggle { display: none !important; }
    
    .topbar { background: transparent !important; border: none !important; border-bottom: 2px solid #ccc !important; padding: 1rem 0 !important; margin-bottom: 2rem !important; }
    
    /* Convert glass panels to simple bordered boxes for print */
    .glass-panel {
        background: transparent !important;
        border: 1px solid #ddd !important;
        box-shadow: none !important;
        color: black !important;
        page-break-inside: avoid;
        margin-bottom: 2rem !important;
        display: block !important;
    }
    
    /* Force text colors to be black or dark visible */
    h1, h2, h3, h4, p, span, div, strong, small { color: black !important; }
    .text-primary, .text-info { color: #1d4ed8 !important; }
    .text-success { color: #15803d !important; }
    .text-danger { color: #b91c1c !important; }
    .text-warning { color: #b45309 !important; }
    
    .report-card, .list-group-item {
        background: transparent !important;
        border: 1px solid #aaa !important;
        page-break-inside: avoid;
    }
    
    .badge {
        border: 1px solid #666;
        color: black !important;
        background: transparent !important;
    }
    
    /* Visibility logic: ONLY show the active view, drop the others physically */
    .view-section { display: none !important; }
    .view-section:not(.hidden) { display: block !important; width: 100% !important; }
    
    /* Force charts to render */
    canvas {
        max-width: 100% !important;
        height: auto !important;
        page-break-inside: avoid;
        display: block !important;
    }
    
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}
