/* Self-hosted Bootstrap + Bootstrap Icons (bundled by Vite instead of loaded from CDN).
   This removes 2 external network round-trips (DNS + TLS + download) on every
   page load, which matters most on mobile/cellular connections. */
@import "bootstrap/dist/css/bootstrap.min.css";
@import "bootstrap-icons/font/bootstrap-icons.css";

:root {
    /* Tell mobile browsers this site is explicitly light-themed. Without
       this, some Android browsers (Chrome/Samsung Internet "force dark")
       auto-invert form field colors, which can make text inside inputs
       (e.g. the qty field) unreadable even though our CSS sets normal
       black-on-white colors. */
    color-scheme: light;

    --brand: #2f5fef;
    --brand-dark: #1f45c9;
    --navy: #16213a;
    --navy-dark: #0e1626;
    --sidebar-w: 264px;
    --ink: #1f2937;
    --muted: #8a93a3;
    --border: #edf0f4;
    --bg: #f5f7fb;
}

* {
    box-sizing: border-box;
}

body {
    background: var(--bg);
    color: var(--ink);
    font-family: "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
}

/* Smoother touch response / no 300ms tap delay on interactive elements */
a, button, .btn, .nav-link {
    touch-action: manipulation;
}

/* ---------- Sidebar ---------- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: #fff;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 1030;
    box-shadow: 2px 0 12px rgba(16, 24, 40, .04);
    /* GPU-accelerated slide, avoids layout thrash on low-end mobile devices */
    will-change: transform;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.5rem 1.25rem;
    background: var(--navy);
    color: #fff;
}

.sidebar-brand .cube {
    width: 52px;
    height: 52px;
    border-radius: .9rem;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--brand), #6a8bff);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.5rem;
}

.sidebar-brand .brand-name {
    font-weight: 700;
    font-size: .95rem;
    line-height: 1.3;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1.25rem .9rem;
}

.sidebar-section {
    text-transform: uppercase;
    font-size: .68rem;
    letter-spacing: .05em;
    color: var(--muted);
    padding: .9rem .6rem .35rem;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: .7rem;
    color: #4b5566;
    font-size: .92rem;
    font-weight: 600;
    padding: .7rem .95rem;
    border-radius: .9rem;
    margin-bottom: .6rem;
    border: 1px solid var(--border);
    background: #fff;
}

.sidebar-nav .nav-link i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
    color: #8a93a3;
}

.sidebar-nav .nav-link:hover {
    border-color: #c9d6ff;
    color: var(--brand);
}

.sidebar-nav .nav-link:hover i {
    color: var(--brand);
}

.sidebar-nav .nav-link.active {
    background: var(--navy);
    border-color: var(--navy);
    color: #fff;
    box-shadow: 0 6px 14px rgba(22, 33, 58, .25);
}

.sidebar-nav .nav-link.active i {
    color: #fff;
}

.sidebar-logout {
    padding: 0 1.1rem 1.25rem;
}

.sidebar-logout button {
    width: 100%;
    background: var(--navy);
    border: 1px solid var(--navy);
    color: #fff;
    border-radius: .9rem;
    padding: .7rem 1rem;
    font-weight: 600;
    font-size: .92rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
}

.sidebar-logout button:hover {
    background: var(--navy-dark);
    border-color: var(--navy-dark);
}

.sidebar-user {
    border-top: 1px solid var(--border);
    padding: .9rem 1.1rem;
    display: flex;
    align-items: center;
    gap: .6rem;
}

.sidebar-user .avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #e7ecff;
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-user .name {
    font-weight: 600;
    font-size: .88rem;
    line-height: 1.1;
}

.sidebar-user .role {
    font-size: .74rem;
    color: var(--muted);
    text-transform: capitalize;
}

/* ---------- Main content ---------- */
.main-wrap {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: .9rem 1.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.topbar h4 {
    margin: 0;
    font-weight: 700;
    font-size: 1.25rem;
}

.topbar button {
    min-width: 44px;
    min-height: 44px;
}

.content-area {
    padding: 1.5rem 1.75rem 2.5rem;
    flex: 1;
}

/* ---------- Components restyle ---------- */
.card {
    border: 1px solid var(--border);
    border-radius: .9rem;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .03);
}

.card-header {
    border-bottom: 1px solid var(--border);
    border-radius: .9rem .9rem 0 0 !important;
}

.card-footer {
    border-top: 1px solid var(--border);
    border-radius: 0 0 .9rem .9rem !important;
}

.table thead th {
    background: #f8fafc;
    color: var(--muted);
    text-transform: uppercase;
    font-size: .72rem;
    letter-spacing: .03em;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
}

.table td,
.table th {
    padding: .85rem 1rem;
    vertical-align: middle;
}

.table>:not(caption)>*>* {
    border-bottom-color: var(--border);
}

/* Smooth momentum scrolling for tables that overflow on mobile */
.table-responsive {
    -webkit-overflow-scrolling: touch;
}

.btn {
    border-radius: .55rem;
    font-weight: 600;
    font-size: .88rem;
}

.btn-primary {
    background: var(--brand);
    border-color: var(--brand);
}

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

.btn-outline-primary {
    color: var(--brand);
    border-color: #c9d6ff;
}

.btn-outline-primary:hover {
    background: var(--brand);
    border-color: var(--brand);
}

.badge-status,
.badge {
    font-weight: 600;
    font-size: .74rem;
    padding: .4em .75em;
    border-radius: 999px;
}

.badge.bg-secondary {
    background: #eef1f5 !important;
    color: #5b6472 !important;
}

.badge.bg-warning {
    background: #fff2df !important;
    color: #c9781f !important;
}

.badge.bg-info {
    background: #e3f4fd !important;
    color: #1783b8 !important;
}

.badge.bg-primary {
    background: #e6ecff !important;
    color: var(--brand) !important;
}

.badge.bg-success {
    background: #e2f7ea !important;
    color: #1f9d55 !important;
}

.badge.bg-danger {
    background: #fde8e8 !important;
    color: #d64545 !important;
}

.badge.bg-light {
    background: #f1f2f4 !important;
    color: #6b7280 !important;
}

.stat-card {
    border-left: 4px solid var(--brand);
    border-radius: .9rem;
}

.form-control,
.form-select {
    border-radius: .55rem;
    border-color: #e2e6ee;
    color: var(--ink);
    background-color: #fff;
    /* 16px min font-size prevents iOS Safari from auto-zooming into the
       field on focus, which is jarring on mobile */
    font-size: max(1rem, 16px);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 .2rem rgba(47, 95, 239, .12);
}

span img {
    width: 80px;
    height: 80px;
}

/* ---------- Sidebar overlay (mobile) ---------- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    z-index: 1025;
}

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

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform .2s ease;
        width: min(var(--sidebar-w), 82vw);
    }

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

    .main-wrap {
        margin-left: 0;
    }

    .content-area {
        padding: 1rem 1rem 2rem;
        /* avoid horizontal overflow bleeding off-screen on small viewports */
        max-width: 100vw;
        overflow-x: hidden;
    }

    .topbar {
        padding: .75rem 1rem;
    }

    h4, .fs-3 {
        font-size: 1.15rem;
    }

    .stat-card .fs-3 {
        font-size: 1.4rem !important;
    }

    .table td,
    .table th {
        padding: .65rem .75rem;
        font-size: .88rem;
    }

    .table thead th {
        white-space: nowrap;
    }

    .table-responsive {
        scrollbar-width: thin;
    }

    .card-header {
        flex-wrap: wrap;
        gap: .4rem;
    }

    .btn {
        font-size: .85rem;
    }

    /* keep tap targets comfortable on touch screens (>= 44px) */
    .sidebar-nav .nav-link,
    .sidebar-logout button {
        min-height: 44px;
    }
}

@media (max-width: 575.98px) {
    .content-area {
        padding: .85rem .75rem 2rem;
    }

    .stat-card {
        padding: .85rem !important;
    }

    /* Stack modal/form action buttons full-width on very small screens */
    .modal-footer .btn,
    form .btn:not(.btn-sm) {
        min-height: 44px;
    }
}

/* ---------- Kotak inputan (form-control/select) khusus mobile ----------
   Hanya berlaku di bawah 767.98px, TIDAK mengubah tampilan desktop sama
   sekali (desktop tetap pakai ukuran default Bootstrap + .form-control di
   atas). Dipakai terutama untuk baris item PR/PO yang banyak input di satu
   baris tabel, supaya tidak terlalu besar/lebar di layar kecil. */
@media (max-width: 767.98px) {
    .form-control,
    .form-select {
        padding: .45rem .65rem;
        font-size: max(.95rem, 16px);
        min-height: 40px;
    }

    textarea.form-control {
        min-height: unset;
    }

    /* Input di dalam tabel (mis. baris barang PR/PO) dibuat lebih ringkas
       supaya tabel tidak terlalu melebar dan lebih nyaman di-scroll. */
    .table input.form-control,
    .table select.form-select {
        padding: .4rem .5rem;
        min-width: 84px;
    }

    .table input[type="number"].form-control {
        min-width: 64px;
    }

    .barang-search-wrap input.form-control {
        min-width: 140px;
    }

    .table td {
        min-width: 0;
    }
}
