:root {
    /* Color Palette - Modern Corporate */
    --primary: #1e3a8a; /* Deep Navy Blue */
    --primary-light: #3b82f6; /* Azure Blue */
    --secondary: #64748b; /* Slate Gray */
    --accent: #f97316; /* Orange - High Visibility */
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #0ea5e9;
    
    /* Backgrounds & Surfaces */
    --bg-main: #f8fafc;
    --bg-sidebar: #0f172a;
    --bg-card: #ffffff;
    
    /* Text Colors */
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-on-primary: #ffffff;
    --text-on-sidebar: #94a3b8;
    --text-on-sidebar-active: #ffffff;
    
    /* Borders & Shadow */
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    /* Spacing & Radii */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --navbar-height: 64px;
    
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

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

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Layout Wrapper */
.wrapper {
    display: flex;
    min-height: 100vh;
}

/* Content Area */
.content-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding-top: var(--navbar-height);
    transition: var(--transition);
    min-width: 0;
}

.wrapper.sidebar-collapsed .content-wrapper {
    margin-left: var(--sidebar-collapsed-width);
}

.container {
    padding: 1.5rem;
    max-width: 1600px;
    margin: 0 auto;
}

/* Top Navbar */
.navbar {
    position: fixed;
    top: 0;
    right: 0;
    left: var(--sidebar-width);
    height: var(--navbar-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 1000;
    transition: var(--transition);
}

.wrapper.sidebar-collapsed .navbar {
    left: var(--sidebar-collapsed-width);
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
}

/* Grid Layouts */
.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }

@media (max-width: 1024px) {
    .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
    .grid-cols-4, .grid-cols-3, .grid-cols-2 { grid-template-columns: 1fr; }
    .content-wrapper { margin-left: 0 !important; }
    .navbar { left: 0 !important; }
}

/* Utility Classes */
.text-primary { color: var(--primary); }
.text-accent { color: var(--accent); }
.bg-primary { background-color: var(--primary); color: white; }
.bg-accent { background-color: var(--accent); color: white; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    text-decoration: none;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: #162e70; transform: translateY(-1px); }

.btn-accent { background: var(--accent); color: white; }
.btn-accent:hover { background: #ea580c; transform: translateY(-1px); }

.btn-outline { border: 1px solid var(--border-color); background: transparent; color: var(--text-main); }
.btn-outline:hover { background: var(--bg-main); }

/* ═══════════════════════════════════
   RESPONSIVE — MOBILE FIRST
   ═══════════════════════════════════ */

/* ── Tabel scroll horizontal di mobile ── */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ── File/action table ── */
.file-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px; /* biar bisa scroll kalau sempit */
}
.file-table th, .file-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}
.file-table thead th { background: #f8fafc; font-size: 0.8rem; font-weight: 600; color: var(--text-muted); }
.file-row:hover { background: #f8fafc; }

/* ── Action buttons ── */
.file-actions { display: flex; gap: 0.4rem; align-items: center; }
.action-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 6px;
    border: 1px solid var(--border-color); background: white;
    color: var(--text-muted); cursor: pointer; font-size: 0.8rem;
    text-decoration: none; transition: var(--transition);
}
.action-btn:hover { background: var(--bg-main); color: var(--primary); border-color: var(--primary); }

/* ── Status badge ── */
.status-badge {
    display: inline-block; padding: 0.25rem 0.75rem;
    border-radius: 999px; font-size: 0.72rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.05em;
    white-space: nowrap;
}

/* ── Modal responsif ── */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.5); z-index: 9999;
    align-items: flex-end; /* mobile: slide up dari bawah */
    justify-content: center;
    padding: 0;
}
.modal-overlay.active { display: flex; }

@media (min-width: 641px) {
    .modal-overlay { align-items: center; padding: 1rem; }
}

.modal-box {
    background: white;
    border-radius: 16px 16px 0 0; /* mobile: rounded atas */
    padding: 1.5rem;
    width: 100%;
    max-width: 100%;
    max-height: 95vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    animation: slideUp 0.25s ease;
}

@media (min-width: 641px) {
    .modal-box {
        border-radius: var(--radius-lg);
        max-width: 860px;
        animation: fadeIn 0.2s ease;
    }
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.97); }
    to   { opacity: 1; transform: scale(1); }
}

/* ── Foto bukti barang — custom file input ── */
.photo-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 10px;
    padding: 1.25rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: #f8fafc;
    position: relative;
}
.photo-upload-area:hover, .photo-upload-area.dragover {
    border-color: var(--primary);
    background: rgba(30,58,138,0.04);
}
.photo-upload-area input[type="file"] {
    position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.photo-upload-area .upload-icon { font-size: 2rem; color: var(--primary); margin-bottom: 0.5rem; }
.photo-upload-area .upload-text { font-size: 0.875rem; color: var(--text-muted); }
.photo-upload-area .upload-text strong { color: var(--primary); }
.photo-upload-area .upload-hint { font-size: 0.75rem; color: #94a3b8; margin-top: 0.25rem; }

/* Tombol kamera khusus mobile */
.btn-camera {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.6rem 1.25rem; border-radius: 8px;
    background: var(--primary); color: white;
    font-size: 0.875rem; font-weight: 600;
    border: none; cursor: pointer; margin-top: 0.75rem;
    width: 100%;
    justify-content: center;
}
.btn-camera i { font-size: 1rem; }

/* Sembunyikan tombol kamera di desktop */
@media (min-width: 768px) {
    .btn-camera { display: none; }
}

/* Preview foto */
.photo-preview-box {
    margin-top: 0.75rem;
    display: none;
    position: relative;
}
.photo-preview-box img {
    width: 100%; max-height: 180px; object-fit: cover;
    border-radius: 8px; border: 1px solid var(--border-color);
}
.photo-preview-box .remove-photo {
    position: absolute; top: 6px; right: 6px;
    background: #ef4444; color: white; border: none;
    border-radius: 50%; width: 26px; height: 26px;
    font-size: 0.75rem; cursor: pointer; display: flex;
    align-items: center; justify-content: center;
}

/* ── Sidebar mobile overlay ── */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
}
.sidebar-overlay.active { display: block; }

@media (max-width: 768px) {
    /* Sidebar tersembunyi di luar layar, muncul saat toggle */
    .sidebar {
        left: calc(-1 * var(--sidebar-width)) !important;
        transition: left 0.3s ease !important;
        width: var(--sidebar-width) !important;
    }
    .sidebar.mobile-open {
        left: 0 !important;
    }
    /* Content full-width di mobile */
    .content-wrapper {
        margin-left: 0 !important;
    }
    .navbar {
        left: 0 !important;
        padding: 0 1rem;
    }
    .navbar-center {
        margin: 0 0.5rem !important; /* kurangi margin search bar */
    }
    /* Sembunyikan search bar di layar sangat kecil jika menumpuk */
    @media (max-width: 480px) {
        .navbar-center { display: none !important; }
    }
    
    /* Header page auto-stack vertical untuk semua halaman */
    .container > div[style*="display: flex"][style*="justify-content: space-between"],
    .container > div[style*="display:flex"][style*="justify-content:space-between"] {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1rem !important;
    }
    .container > div[style*="display: flex"][style*="justify-content: space-between"] > div,
    .container > div[style*="display:flex"][style*="justify-content:space-between"] > div {
        width: 100%;
    }
    .container > div[style*="display: flex"][style*="justify-content: space-between"] .btn,
    .container > div[style*="display:flex"][style*="justify-content:space-between"] .btn {
        width: 100%;
        justify-content: center;
    }

    /* Grid stack di mobile dan reset grid-column span */
    .grid-cols-2, .grid-cols-3, .grid-cols-4 {
        grid-template-columns: 1fr !important;
    }
    .grid > * {
        grid-column: span 1 !important;
    }

    /* Auto scroll horizontal pada card tabel agar tidak merusak layout */
    .card {
        padding: 1rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .card table {
        min-width: 600px; /* Force scrollable table */
    }

    /* Input touch-friendly */
    input, select, textarea {
        font-size: 16px !important; /* cegah zoom iOS saat focus */
        min-height: 44px;
    }
    /* Action button lebih besar untuk sentuh */
    .action-btn { width: 36px; height: 36px; font-size: 0.9rem; }
}

@media (max-width: 480px) {
    .file-actions { gap: 0.25rem; }
    .action-btn { width: 32px; height: 32px; font-size: 0.8rem; }
    h1 { font-size: 1.4rem !important; }
}
