@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
    --bulog-blue: #5693e2;
    --bulog-blue-dark: #3f7ecb;
    --bulog-navy: hsl(214, 57%, 57%);
    --bulog-navy-active: #0c2b54;
    --bulog-accent-orange: #f59e0b;
    --bulog-accent-green: #10b981;
    --bulog-bg-gray: #f4f7fb;
    --sidebar-width: 260px;
}

* {
    box-sizing: border-box;
}

html,
body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bulog-bg-gray);
    color: #1e293b;
    margin: 0;
    padding: 0;
    max-width: 100%;
    overflow-x: hidden;
}

/* Wrapper utama agar flex child tidak melebihi lebar viewport */
.app-shell {
    display: flex;
    min-height: 100vh;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

/* Sidebar Styles */
.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    max-width: 85vw;
    background: linear-gradient(180deg, #1877f2 0%, #1565c0 100%);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    z-index: 1050;
    overflow-y: auto;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(12, 43, 84, 0.14);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.52);
    backdrop-filter: blur(2px);
    z-index: 1040;
}

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

.sidebar-header {
    padding: 20px 18px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.sidebar-brand-img {
    height: 42px;
    width: auto;
    max-width: 180px;
    object-fit: contain;
}

.sidebar-close-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #ffffff;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.sidebar-close-btn:hover {
    background: rgba(255, 255, 255, 0.28);
}

.sidebar-role-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.1px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.72);
    margin: 16px 20px 8px;
}

.sidebar-nav {
    list-style: none;
    padding: 0 12px;
    margin: 0;
    flex: 1;
}

.sidebar-nav-item {
    margin-bottom: 4px;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: rgba(255, 255, 255, 0.92);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    border-radius: 10px;
    transition: all 0.2s ease;
    line-height: 1.3;
}

.sidebar-nav-link:hover {
    background-color: rgba(255, 255, 255, 0.14);
    color: #ffffff;
}

.sidebar-nav-link.active {
    background-color: var(--bulog-navy-active);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(12, 43, 84, 0.3);
}

.sidebar-nav-link svg,
.sidebar-nav-link i {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-footer {
    padding: 16px 14px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.2s;
}

.btn-logout:hover {
    background-color: rgba(255, 255, 255, 0.16);
}

.sidebar-caption {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.68);
    margin-top: 12px;
    padding-left: 6px;
    line-height: 1.4;
}

/* Mobile Topbar */
.mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: linear-gradient(90deg, #1877f2 0%, #1565c0 100%);
    color: #ffffff;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 12px rgba(12, 43, 84, 0.16);
}

.mobile-topbar-logo {
    height: 36px;
    width: auto;
    object-fit: contain;
}

/* Main Content Area */
.app-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    background:
        linear-gradient(rgba(244, 247, 251, 0.88), rgba(244, 247, 251, 0.94)),
        url('/assets/images/dashboard-mockup.png') no-repeat top right / cover fixed;
}

.main-header {
    padding: 24px 32px 12px;
}

.breadcrumb-label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--bulog-blue);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.page-title {
    font-size: 26px;
    font-weight: 800;
    color: #0f172a;
    margin: 0;
    line-height: 1.25;
    word-break: break-word;
}

.page-subtitle {
    font-size: 13px;
    color: #64748b;
    margin: 4px 0 0;
}

.main-body {
    padding: 16px 32px 32px;
    flex: 1;
    min-width: 0;
}

/* Card Styles */
.custom-card {
    background: #ffffff;
    border-radius: 16px;
    padding: 20px;
    border: 1px solid rgba(226, 232, 240, 0.85);
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.04);
    margin-bottom: 24px;
    max-width: 100%;
}

.card-title {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 4px;
}

.card-subtitle {
    font-size: 12px;
    color: #64748b;
    margin-bottom: 16px;
}

/* Stat Box Cards */
.stat-box {
    background: #ffffff;
    border-radius: 16px;
    padding: 18px 20px;
    border: 1px solid rgba(226, 232, 240, 0.85);
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.04);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    height: 100%;
}

.stat-box .stat-label {
    font-size: 13px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 2px;
}

.stat-box .stat-sub {
    font-size: 11px;
    color: #94a3b8;
    margin-bottom: 8px;
}

.stat-box .stat-value {
    font-size: 30px;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.1;
}

.stat-box .stat-icon-wrapper {
    width: 50px;
    height: 50px;
    flex-shrink: 0;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #eff6ff;
    color: var(--bulog-blue);
    font-size: 22px;
}

/* Responsive Table Wrapper */
.overflow-x-auto,
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Table Design */
.custom-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.custom-table th {
    background-color: #f1f5f9;
    color: #475569;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 14px;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
}

.custom-table th:first-child {
    border-top-left-radius: 10px;
    border-bottom-left-radius: 10px;
}

.custom-table th:last-child {
    border-top-right-radius: 10px;
    border-bottom-right-radius: 10px;
}

.custom-table td {
    padding: 12px 14px;
    font-size: 13px;
    color: #1e293b;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.custom-table tr:hover td {
    background-color: #f8fafc;
}

/* Badge Styles */
.badge-status {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 600;
}

.badge-warning {
    background-color: #fef3c7;
    color: #92400e;
}

.badge-info {
    background-color: #e0f2fe;
    color: #0369a1;
}

.badge-success {
    background-color: #dcfce7;
    color: #15803d;
}

.badge-danger {
    background-color: #fee2e2;
    color: #b91c1c;
}

.badge-hmac-valid {
    background-color: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

.badge-hmac-invalid {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

/* Buttons */
.btn-bulog-primary {
    background-color: var(--bulog-blue);
    color: #ffffff;
    font-weight: 600;
    padding: 9px 18px;
    border-radius: 10px;
    border: none;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-bulog-primary:hover {
    background-color: var(--bulog-blue-dark);
    color: #ffffff;
}

.btn-bulog-navy {
    background-color: var(--bulog-navy);
    color: #ffffff;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
}

.btn-bulog-navy:hover {
    background-color: #081d3a;
    color: #ffffff;
}

.btn-xs {
    padding: 0.25rem 0.55rem;
    font-size: 0.75rem;
    border-radius: 6px;
}

/* Progress bar */
.custom-progress {
    height: 10px;
    border-radius: 9999px;
    background-color: #e2e8f0;
    overflow: hidden;
}

.custom-progress-bar {
    height: 100%;
    border-radius: 9999px;
}

/* Tablet & Mobile Drawer (< 992px) */
@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
    }

    .app-sidebar.show {
        transform: translateX(0);
    }

    .app-main {
        margin-left: 0;
        width: 100%;
    }

    .main-header {
        padding: 18px 20px 10px;
    }

    .main-body {
        padding: 12px 20px 24px;
    }

    .page-title {
        font-size: 22px;
    }
}

/* Smartphone (<= 768px) */
@media (max-width: 768px) {
    html,
    body {
        max-width: 100vw;
        overflow-x: hidden !important;
    }

    img,
    video,
    canvas {
        max-width: 100%;
    }

    .app-shell,
    .app-main,
    .main-header,
    .main-body,
    .custom-card {
        max-width: 100%;
        min-width: 0;
    }

    /* Pastikan container multi-kolom kustom otomatis menumpuk vertikal 1 kolom di HP */
    .two-col-flex,
    .responsive-stack-mobile {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
    }

    .two-col-grid {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .responsive-stack-mobile > *,
    .responsive-filter-form > .form-control,
    .responsive-filter-form > .form-select,
    .responsive-filter-form > .btn {
        width: 100% !important;
        max-width: 100% !important;
    }

    .main-header {
        padding: 16px 14px 8px;
    }

    .main-body {
        padding: 10px 14px 24px;
    }

    .page-title {
        font-size: 20px;
    }

    .page-subtitle {
        font-size: 12px;
    }

    .custom-card {
        padding: 15px;
        border-radius: 14px;
        margin-bottom: 16px;
    }

    .card-title {
        font-size: 16px;
    }

    .stat-box {
        padding: 14px 16px;
    }

    .stat-box .stat-value {
        font-size: 24px;
    }

    .stat-box .stat-icon-wrapper {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }

    .custom-table th,
    .custom-table td {
        padding: 10px 10px;
        font-size: 12px;
    }

    .header-actions-wrap {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .header-actions-wrap > a,
    .header-actions-wrap > button,
    .header-actions-wrap > form {
        flex: 1 1 auto;
    }

    .header-actions-wrap > form > button {
        width: 100%;
    }

    .pagination {
        flex-wrap: wrap;
        gap: 4px;
    }

    .modal-dialog {
        margin: 0.65rem;
    }

    .modal-body {
        padding: 1rem;
    }

    .modal-footer {
        flex-wrap: wrap;
        gap: 8px;
    }

    .modal-footer .btn {
        flex: 1 1 auto;
    }
}
