/* ============================================================
   UD. MAJU LANCAR - Custom Stylesheet
   Sistem Manajemen Gudang Jagung v2.0
   ============================================================ */

/* --- VARIABEL --- */
:root {
    --sidebar-width:       260px;
    --sidebar-collapsed:   0px;
    --topbar-height:       60px;
    --primary:             #f59e0b;
    --primary-dark:        #d97706;
    --primary-light:       #fef3c7;
    --sidebar-bg:          #1e293b;
    --sidebar-hover:       rgba(255,255,255,.07);
    --sidebar-active-bg:   rgba(245,158,11,.15);
    --sidebar-active-text: #f59e0b;
    --sidebar-text:        rgba(255,255,255,.65);
    --sidebar-section:     rgba(255,255,255,.3);
    --topbar-bg:           #ffffff;
    --body-bg:             #f1f5f9;
    --card-shadow:         0 2px 12px rgba(0,0,0,.07);
    --card-shadow-lg:      0 8px 30px rgba(0,0,0,.12);
    --border-color:        #e2e8f0;
    --text-primary:        #1e293b;
    --text-muted:          #64748b;
    --radius:              .75rem;
    --radius-sm:           .5rem;
    --transition:          .25s ease;
}

/* --- BASE --- */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--body-bg);
    color: var(--text-primary);
    overflow-x: hidden;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform var(--transition);
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.1) transparent;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

/* Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    flex-shrink: 0;
}

.sidebar-brand-icon {
    width: 40px; height: 40px;
    background: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.brand-name {
    display: block;
    color: #fff;
    font-weight: 800;
    font-size: .92rem;
    line-height: 1.2;
}

.brand-sub {
    display: block;
    color: var(--sidebar-text);
    font-size: .72rem;
}

/* User info sidebar */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    flex-shrink: 0;
}

.sidebar-user-avatar {
    font-size: 2rem;
    color: var(--primary);
    line-height: 1;
}

.sidebar-user-name {
    display: block;
    color: #fff;
    font-weight: 600;
    font-size: .88rem;
}

.badge-role {
    font-size: .68rem;
    letter-spacing: .04em;
    padding: 2px 7px;
    border-radius: 20px;
}

/* Menu */
.sidebar-menu {
    list-style: none;
    margin: 0;
    padding: 8px 0;
    flex: 1;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.1) transparent;
}

.sidebar-section {
    padding: 14px 16px 4px;
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--sidebar-section);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    color: var(--sidebar-text);
    font-size: .88rem;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all .2s;
}

.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
    border-left-color: rgba(245,158,11,.5);
}

.sidebar-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    border-left-color: var(--primary);
    font-weight: 600;
}

.sidebar-link i {
    font-size: 1rem;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

/* Footer sidebar */
.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,.08);
    padding: 8px 0;
    flex-shrink: 0;
}

.sidebar-logout:hover {
    background: rgba(239,68,68,.12) !important;
    color: #f87171 !important;
    border-left-color: #ef4444 !important;
}



/* ============================================================
   NOTIFIKASI
   ============================================================ */
.notif-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #ef4444;
    color: #fff;
    font-size: .6rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    line-height: 1;
    animation: pulse-notif 2s infinite;
}

@keyframes pulse-notif {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.2); }
}

.notif-dropdown {
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,.15);
    border: 1px solid #e2e8f0;
}

.notif-item {
    color: #334155;
    transition: background .15s;
}
.notif-item:hover {
    background: #f8fafc;
}

.notif-icon {
    width: 32px;
    flex-shrink: 0;
    padding-top: 2px;
}

.notif-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 6px;
}

.btn-topbar-notif {
    position: relative;
}
.btn-topbar-notif:hover {
    opacity: .8;
}

/* Hamburger button */
.btn-hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.4rem;
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 6px;
    margin-right: 8px;
    transition: background .2s;
}
.btn-hamburger:hover {
    background: rgba(0,0,0,.06);
}

@media (max-width: 992px) {
    .btn-hamburger {
        display: flex !important;
    }
}

/* Overlay mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1039;
}

.sidebar-overlay.active { display: block; }

/* ============================================================
   MAIN WRAPPER
   ============================================================ */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease, width 0.3s ease;
}

/* Sidebar tersembunyi di desktop */
body.sidebar-hidden .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
}
body.sidebar-hidden .main-wrapper {
    margin-left: 0;
}
/* Tombol toggle berubah ikon saat sidebar tersembunyi */
body.sidebar-hidden #sidebarToggle .bi-list::before {
    content: "\f479"; /* bi-layout-sidebar */
}
/* Overlay saat sidebar muncul di desktop (opsional) */
body.sidebar-hidden .sidebar-overlay-desktop {
    display: none !important;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
    height: var(--topbar-height);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: 0 1px 8px rgba(0,0,0,.06);
    flex-shrink: 0;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.btn-sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    line-height: 1;
    transition: background .2s;
    display: flex !important;
    align-items: center;
}

.btn-sidebar-toggle:hover { background: var(--body-bg); color: var(--text-primary); }

.topbar-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.topbar-date {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .83rem;
    color: var(--text-muted);
}

.btn-topbar-user {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    font-size: .88rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: background .2s;
}

.btn-topbar-user:hover { background: var(--body-bg); }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content { flex: 1; }

.main-footer {
    padding: 14px 20px;
    text-align: center;
    font-size: .78rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    background: var(--topbar-bg);
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius) !important;
    box-shadow: var(--card-shadow) !important;
}

.card-header {
    background: #fff !important;
    border-bottom: 1px solid var(--border-color) !important;
    font-weight: 700;
    padding: 14px 20px !important;
}

.card-title-icon {
    color: var(--primary);
    margin-right: 6px;
}

/* ============================================================
   STAT CARDS (Dashboard)
   ============================================================ */
.stat-card {
    border-radius: var(--radius) !important;
    border: none !important;
    box-shadow: var(--card-shadow) !important;
    transition: transform .2s, box-shadow .2s;
}

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

.stat-icon-wrap {
    width: 54px; height: 54px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-icon-yellow  { background: #fef3c7; color: #d97706; }
.stat-icon-green   { background: #d1fae5; color: #059669; }
.stat-icon-red     { background: #fee2e2; color: #dc2626; }
.stat-icon-blue    { background: #dbeafe; color: #2563eb; }
.stat-icon-purple  { background: #ede9fe; color: #7c3aed; }
.stat-icon-orange  { background: #ffedd5; color: #ea580c; }

.stat-label {
    font-size: .78rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 2px;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

/* ============================================================
   TABEL
   ============================================================ */
.table > thead > tr > th {
    background: #f8fafc;
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border-color) !important;
    white-space: nowrap;
    padding: 10px 14px;
}

.table > tbody > tr > td {
    padding: 10px 14px;
    vertical-align: middle;
    border-color: var(--border-color);
    font-size: .9rem;
}

.table-hover > tbody > tr:hover > td { background: #f8fafc; }

.table-empty td {
    text-align: center;
    padding: 40px !important;
    color: var(--text-muted);
}

/* ============================================================
   BADGE KUSTOM
   ============================================================ */
.badge-masuk    { background: #d1fae5; color: #065f46; }
.badge-keluar   { background: #fee2e2; color: #991b1b; }
.badge-aktif    { background: #dbeafe; color: #1e40af; }
.badge-selesai  { background: #f1f5f9; color: #64748b; }
.badge-override { background: #fef3c7; color: #92400e; }

/* ============================================================
   FORM
   ============================================================ */
.form-label { font-weight: 600; font-size: .88rem; margin-bottom: 5px; }
.required   { color: #ef4444; }

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 .2rem rgba(245,158,11,.2);
}

.form-control[readonly] { background: #f8fafc; }

.input-group-text {
    background: #f8fafc;
    border-color: var(--border-color);
    font-size: .88rem;
    color: var(--text-muted);
}

/* ============================================================
   TOMBOL
   ============================================================ */
.btn-primary {
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #fff !important;
    font-weight: 600;
}

.btn-primary:hover {
    background-color: var(--primary-dark) !important;
    border-color: var(--primary-dark) !important;
}

.btn-outline-primary {
    color: var(--primary) !important;
    border-color: var(--primary) !important;
}

.btn-outline-primary:hover {
    background-color: var(--primary) !important;
    color: #fff !important;
}

/* ============================================================
   ALERT
   ============================================================ */
.alert { border-radius: var(--radius-sm); font-size: .9rem; }

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.page-header-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
}

/* ============================================================
   STOK BADGE
   ============================================================ */
.stok-badge {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .78rem;
    font-weight: 700;
}

.stok-ok      { background: #d1fae5; color: #065f46; }
.stok-warning { background: #fef3c7; color: #92400e; }
.stok-empty   { background: #fee2e2; color: #991b1b; }

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.progress {
    height: 8px;
    border-radius: 20px;
    background: var(--border-color);
}

.progress-bar {
    background: var(--primary);
    border-radius: 20px;
}

/* ============================================================
   RESPONSIVE — TABLET (≤ 992px)
   ============================================================ */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
        box-shadow: var(--card-shadow-lg);
    }

    .main-wrapper {
        margin-left: 0 !important;
    }

    .btn-sidebar-toggle {
        display: flex !important;
        align-items: center;
    }
}

/* ============================================================
   RESPONSIVE — MOBILE (≤ 576px)
   ============================================================ */
@media (max-width: 576px) {
    .topbar { padding: 0 12px; }
    .topbar-title { font-size: .95rem; }

    .stat-value { font-size: 1.15rem; }
    .stat-icon-wrap { width: 44px; height: 44px; font-size: 1.15rem; }

    .table > thead > tr > th,
    .table > tbody > tr > td { padding: 8px 10px; font-size: .82rem; }

    .page-header { flex-direction: column; align-items: flex-start; }

    .card-header { padding: 12px 16px !important; }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
    .sidebar, .sidebar-overlay, .topbar, .main-footer,
    .btn, .page-header .btn, form, .no-print { display: none !important; }
    .main-wrapper { margin: 0 !important; }
    .main-content { padding: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; }
    body { background: #fff !important; }
}
