/* ============================================================
   VEKSI.ID — Custom Stylesheet
   ============================================================ */

:root {
    --navy: #1A3A6E;
    --navy-dark: #142d57;
    --navy-light: #1e4480;
    --emerald: #2ECC8A;
    --emerald-dark: #25b377;
    --bg-light: #F4F6F9;
    --text-primary: #2D3436;
    --text-secondary: #636E72;
    --danger: #E74C3C;
    --warning: #F39C12;
    --success: #27AE60;
    --border: #dee2e6;
    --sidebar-width: 255px;
    --topbar-height: 60px;
}

/* ---- Base ---- */
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-primary);
    font-size: 0.9rem;
    overflow-x: hidden;
    max-width: 100vw;
}

a { color: var(--navy); }
a:hover { color: var(--emerald-dark); }

/* ---- Sidebar ---- */
#sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    max-height: 100vh;
    background: var(--navy);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    transition: transform 0.3s ease;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden;
}

#sidebar .sidebar-brand {
    padding: 18px 20px;
    background: var(--navy-dark);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: var(--topbar-height);
    flex-shrink: 0;
    flex-grow: 0;
}

#sidebar .sidebar-brand .brand-text {
    color: #fff;
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: 0.5px;
}

#sidebar .sidebar-brand .brand-tagline {
    color: var(--emerald);
    font-size: 0.7rem;
    display: block;
    font-weight: 400;
}

#sidebar .sidebar-menu {
    padding: 12px 0;
    flex: 1 1 0;
    min-height: 0;        /* KUNCI: tanpa ini flex child tidak bisa scroll */
    overflow-y: auto;
    overflow-x: hidden;
}

/* Scrollbar tipis di dalam menu */
#sidebar .sidebar-menu::-webkit-scrollbar { width: 3px; }
#sidebar .sidebar-menu::-webkit-scrollbar-track { background: transparent; }
#sidebar .sidebar-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 2px; }
#sidebar .sidebar-menu::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.35); }

#sidebar .sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
    background: var(--navy-dark);
    flex-shrink: 0;
    flex-grow: 0;
}

#sidebar .sidebar-footer .user-info {
    color: rgba(255,255,255,0.8);
    font-size: 0.8rem;
}

#sidebar .sidebar-footer .user-role {
    color: var(--emerald);
    font-size: 0.7rem;
}

#sidebar .menu-label {
    color: rgba(255,255,255,0.4);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    padding: 10px 20px 4px;
}

#sidebar .nav-link {
    color: rgba(255,255,255,0.75);
    padding: 9px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-left: 3px solid transparent;
    transition: all 0.2s;
    font-size: 0.875rem;
    border-radius: 0;
    white-space: nowrap;
}

#sidebar .nav-link i {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

#sidebar .nav-link:hover {
    color: #fff;
    background: rgba(255,255,255,0.08);
    border-left-color: var(--emerald);
}

#sidebar .nav-link.active {
    color: #fff;
    background: rgba(46,204,138,0.15);
    border-left-color: var(--emerald);
    font-weight: 600;
}

#sidebar .nav-link .badge {
    margin-left: auto;
    font-size: 0.65rem;
}

/* Menu terkunci — fitur belum tersedia di plan saat ini */
#sidebar .nav-link-upgrade {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255,255,255,0.45);
    padding: 9px 20px;
    font-size: 0.9rem;
    text-decoration: none;
    border-left: 3px solid #F39C12;
    background: rgba(243,156,18,0.08);
    transition: background .15s;
}

#sidebar .nav-link-upgrade:hover {
    background: rgba(243,156,18,0.18);
    color: rgba(255,255,255,0.7);
}

#sidebar .nav-link-upgrade i {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

#sidebar .nav-link-upgrade .badge {
    margin-left: auto;
    font-size: 0.65rem;
    flex-shrink: 0;
}

#sidebar .sidebar-submenu {
    background: rgba(0,0,0,0.15);
}

#sidebar .sidebar-submenu .nav-link {
    padding-left: 46px;
    font-size: 0.825rem;
}

#sidebar .sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
    background: var(--navy-dark);
    flex-shrink: 0;
}

#sidebar .sidebar-footer .user-info {
    color: rgba(255,255,255,0.8);
    font-size: 0.8rem;
}

#sidebar .sidebar-footer .user-role {
    color: var(--emerald);
    font-size: 0.7rem;
}

/* ---- Main Content ---- */
#main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    min-width: 0;
    overflow-x: clip;
    transition: margin-left 0.3s ease;
}

/* ---- Topbar ---- */
#topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 999;
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

#topbar .page-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
    flex: 1;
}

#topbar .btn-toggle-sidebar {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-secondary);
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
}

#topbar .btn-toggle-sidebar:hover {
    background: var(--bg-light);
    color: var(--navy);
}

.notif-bell {
    position: relative;
    cursor: pointer;
}

.notif-bell .badge-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger);
    color: #fff;
    font-size: 0.6rem;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---- Content Area ---- */
.content-area {
    padding: 24px;
}

/* ---- KPI Cards ---- */
.kpi-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px 22px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.06);
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
    height: 100%;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.kpi-card .kpi-icon {
    width: 46px;
    height: 46px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.kpi-card .kpi-icon.navy { background: rgba(26,58,110,0.1); color: var(--navy); }
.kpi-card .kpi-icon.emerald { background: rgba(46,204,138,0.1); color: var(--emerald-dark); }
.kpi-card .kpi-icon.warning { background: rgba(243,156,18,0.1); color: var(--warning); }
.kpi-card .kpi-icon.danger { background: rgba(231,76,60,0.1); color: var(--danger); }

.kpi-card .kpi-value {
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.kpi-card .kpi-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ---- Cards ---- */
.card {
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    padding: 14px 18px;
    border-radius: 10px 10px 0 0 !important;
}

.card-header.navy {
    background: var(--navy);
    color: #fff;
}

/* ---- Tables ---- */
.table {
    font-size: 0.875rem;
}

.table thead th {
    background: var(--bg-light);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.table tbody tr:hover {
    background: rgba(26,58,110,0.03);
}

/* ---- Buttons ---- */
.btn-navy {
    background-color: var(--navy);
    color: #fff;
    border-color: var(--navy);
}

.btn-navy:hover {
    background-color: var(--navy-dark);
    color: #fff;
    border-color: var(--navy-dark);
}

.btn-emerald {
    background-color: var(--emerald);
    color: #fff;
    border-color: var(--emerald);
}

.btn-emerald:hover {
    background-color: var(--emerald-dark);
    color: #fff;
}

/* ---- Status Timeline ---- */
.production-timeline {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.timeline-step {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 500;
}

.timeline-step.done {
    background: rgba(46,204,138,0.15);
    color: var(--emerald-dark);
}

.timeline-step.active {
    background: var(--navy);
    color: #fff;
}

.timeline-step.pending {
    background: var(--bg-light);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.timeline-step .arrow {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

/* ---- Alert Banners ---- */
.alert-trial {
    background: linear-gradient(135deg, #fff3cd, #ffeeba);
    border: 1px solid #ffc107;
    border-radius: 10px;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-expired {
    background: linear-gradient(135deg, #fde8e8, #f8d7da);
    border: 1px solid var(--danger);
    border-radius: 10px;
    padding: 14px 18px;
}

/* ---- Forms ---- */
.form-label {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.form-control, .form-select {
    font-size: 0.875rem;
    border-color: var(--border);
    border-radius: 8px;
}

.form-control:focus, .form-select:focus {
    border-color: var(--navy);
    box-shadow: 0 0 0 0.2rem rgba(26,58,110,0.15);
}

.form-section-title {
    font-weight: 600;
    color: var(--navy);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--emerald);
    margin-bottom: 16px;
}

/* ---- Pagination ---- */
.page-link {
    color: var(--navy);
    font-size: 0.85rem;
}

.page-item.active .page-link {
    background-color: var(--navy);
    border-color: var(--navy);
}

/* ---- Toast ---- */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 360px;
}

.toast-item {
    background: #fff;
    border-radius: 10px;
    padding: 14px 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
    border-left: 4px solid var(--navy);
    display: flex;
    align-items: flex-start;
    gap: 10px;
    animation: slideInRight 0.3s ease;
    font-size: 0.875rem;
}

.toast-item.success { border-left-color: var(--success); }
.toast-item.danger  { border-left-color: var(--danger); }
.toast-item.warning { border-left-color: var(--warning); }

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

/* ---- Landing Page ---- */
.landing-navbar {
    background: var(--navy) !important;
    padding: 14px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}

.landing-navbar .navbar-brand {
    font-size: 1.4rem;
    font-weight: 800;
    color: #fff !important;
}

.landing-navbar .nav-link {
    color: rgba(255,255,255,0.85) !important;
    font-weight: 500;
    padding: 6px 14px !important;
}

.landing-navbar .nav-link:hover { color: var(--emerald) !important; }

.hero-section {
    background: linear-gradient(135deg, var(--navy) 0%, #0f2548 60%, #1a3a6e 100%);
    color: #fff;
    padding: 90px 0 80px;
    position: relative;
    overflow: hidden;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 500px;
    height: 500px;
    background: rgba(46,204,138,0.06);
    border-radius: 50%;
}

.hero-section h1 {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1.2;
}

.hero-section h1 span { color: var(--emerald); }

.hero-section .lead {
    font-size: 1.1rem;
    color: rgba(255,255,255,0.8);
    line-height: 1.7;
}

.btn-cta {
    background: var(--emerald);
    color: #fff;
    font-weight: 700;
    padding: 14px 32px;
    border-radius: 50px;
    font-size: 1rem;
    border: none;
    box-shadow: 0 4px 20px rgba(46,204,138,0.4);
    transition: all 0.3s;
}

.btn-cta:hover {
    background: var(--emerald-dark);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(46,204,138,0.5);
}

.feature-card {
    background: #fff;
    border-radius: 14px;
    padding: 28px 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
    height: 100%;
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.1);
}

.feature-card .feature-icon {
    width: 56px;
    height: 56px;
    background: rgba(26,58,110,0.08);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--navy);
    margin-bottom: 16px;
}

.feature-card h5 {
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.pricing-card {
    background: #fff;
    border-radius: 16px;
    padding: 30px 24px;
    border: 2px solid var(--border);
    transition: all 0.3s;
    height: 100%;
    position: relative;
}

.pricing-card.featured {
    border-color: var(--navy);
    box-shadow: 0 8px 30px rgba(26,58,110,0.15);
    transform: scale(1.03);
}

.pricing-card .price {
    font-size: 2rem;
    font-weight: 800;
    color: var(--navy);
}

.pricing-card .price small {
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--text-secondary);
}

.pricing-card .feature-list li {
    padding: 6px 0;
    font-size: 0.88rem;
    border-bottom: 1px dashed #f0f0f0;
}

.pricing-card .feature-list li:last-child { border-bottom: none; }

.testimonial-card {
    background: #fff;
    border-radius: 14px;
    padding: 24px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
    border: 1px solid var(--border);
}

.testimonial-card .stars { color: #f39c12; }

.section-title {
    text-align: center;
    margin-bottom: 48px;
}

.section-title h2 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
}

.section-title .subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    max-width: 540px;
    margin: 10px auto 0;
}

.section-title .accent-line {
    width: 50px;
    height: 4px;
    background: var(--emerald);
    margin: 12px auto 0;
    border-radius: 2px;
}

/* ---- Admin Layout ---- */
.admin-wrapper {
    display: flex;
}

.admin-sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--navy);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.admin-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
}

/* ---- Badges ---- */
.badge { font-weight: 500; font-size: 0.72rem; }

/* ---- Utilities ---- */
.text-navy { color: var(--navy) !important; }
.text-emerald { color: var(--emerald) !important; }
.bg-navy { background-color: var(--navy) !important; }
.bg-emerald { background-color: var(--emerald) !important; }

.fw-600 { font-weight: 600; }
.cursor-pointer { cursor: pointer; }

.divider {
    height: 1px;
    background: var(--border);
    margin: 16px 0;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-light); }
::-webkit-scrollbar-thumb { background: #c0c7d0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a0a9b4; }

/* ---- Loading Spinner ---- */
.spinner-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}

/* ---- Responsive ---- */
@media (max-width: 992px) {
    #sidebar {
        transform: translateX(-100%);
    }
    #sidebar.show {
        transform: translateX(0);
    }
    #main-content {
        margin-left: 0;
    }
    .admin-main {
        margin-left: 0;
    }
    .admin-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
    }
    .admin-sidebar.show {
        transform: translateX(0);
    }
    .pricing-card.featured {
        transform: scale(1);
    }
}

@media (max-width: 576px) {
    .content-area { padding: 12px; }
    .content-area, .content-area * { box-sizing: border-box; }
    .hero-section h1 { font-size: 1.8rem; }
    .kpi-card .kpi-value { font-size: 1.2rem; }
    .kpi-card { padding: 10px 12px; }
    .kpi-card .kpi-icon { width: 36px; height: 36px; font-size: 1rem; }
}

/* ============================================================
   GLOBAL MOBILE RESPONSIVE — applies to all module pages
   ============================================================ */

/* Page header: button wraps on small screens */
@media (max-width: 575px) {
    /* Header row wraps naturally with flex-wrap gap */
    .content-area > div:first-child.d-flex,
    .content-area .page-header-row {
        flex-wrap: wrap;
        gap: 10px;
    }
    /* Tombol "Tambah" full width on very small screens */
    .content-area > div:first-child.d-flex .btn {
        font-size: .82rem;
    }
    /* Card header with form: stack vertically */
    .card-header > form.d-flex,
    .card-header-form { flex-wrap: wrap; }
    .card-header > form.d-flex .form-control,
    .card-header > form.d-flex .form-select {
        max-width: 100% !important;
        flex: 1 1 120px;
    }
    /* Tables with many columns: allow horizontal scroll */
    .table-responsive { -webkit-overflow-scrolling: touch; }

    /* Modal dialogs full screen on mobile */
    .modal-dialog { margin: 0.5rem; }
    .modal-dialog-large { max-width: calc(100vw - 1rem); }
}

/* ============================================================
   MOBILE CARD LIST ITEMS — card visual per item
   ============================================================ */

/* Wrapper container untuk card list di mobile */
.mobile-card-list {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 0;
    background: #f0f2f5; /* abu-abu tipis sebagai "grout" antar card */
}

/* Setiap item SO sebagai card */
.so-card-item {
    display: block;
    background: #fff;
    border: none;
    border-left: 4px solid var(--navy);
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 10px;
    text-decoration: none;
    color: var(--text-primary);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    transition: box-shadow 0.15s, transform 0.1s;
}
.so-card-item:last-child {
    margin-bottom: 0;
}
.so-card-item:hover, .so-card-item:active {
    box-shadow: 0 3px 12px rgba(26,58,110,0.15);
    transform: translateY(-1px);
    color: var(--text-primary);
    text-decoration: none;
}
.so-card-item .so-nomor { font-weight: 700; color: var(--navy); font-size: .92rem; }
.so-card-item .so-pelanggan { color: var(--text-secondary); font-size: .82rem; margin-top: 3px; }
.so-card-item .so-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; }
.so-card-item .so-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid #f0f2f5; }

/* Setiap item Produksi/lainnya sebagai card */
.rp-card-item {
    background: #fff;
    border: 1px solid var(--border);
    border-left: 3px solid var(--emerald-dark);
    border-radius: 10px;
    padding: 12px 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    transition: box-shadow 0.15s, transform 0.1s;
}
.rp-card-item:hover {
    box-shadow: 0 3px 10px rgba(26,58,110,0.10);
    transform: translateY(-1px);
}
.rp-card-item .rp-nama { font-weight: 700; color: var(--navy); font-size: .9rem; }
.rp-card-item .rp-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.rp-card-item .so-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }

/* Header aksi mobile — tombol full width */
@media (max-width: 767px) {
    .mobile-header-actions { flex-direction: column; gap: 8px !important; }
    .mobile-header-actions .btn { width: 100%; justify-content: center; }

    /* Tab + search stacked */
    .mobile-tab-search { flex-direction: column; gap: 8px; }
    .mobile-tab-search .nav-tabs { overflow-x: auto; flex-wrap: nowrap; white-space: nowrap; }
    .mobile-tab-search form { width: 100%; }
    .mobile-tab-search form .form-control { width: 100% !important; max-width: none !important; }
    .mobile-tab-search form .d-flex { width: 100%; }

    /* Timeline scroll horizontal di mobile */
    .production-timeline { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
    .timeline-step { white-space: nowrap; font-size: .75rem; padding: 4px 8px; }

    /* Detail page header stack */
    .detail-header-wrap { flex-direction: column; align-items: flex-start !important; gap: 12px; }
    .detail-header-wrap .btn-group-actions { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
    .detail-header-wrap .btn-group-actions .btn { flex: 1 1 auto; justify-content: center; font-size: .8rem; }

    /* Table di detail: collapse ke stack */
    .table-stack-mobile thead { display: none; }
    .table-stack-mobile tbody tr { display: block; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; padding: 4px 8px; }
    .table-stack-mobile tbody td { display: flex; justify-content: space-between; align-items: center; border: none; padding: 4px 0; font-size: .83rem; }
    .table-stack-mobile tbody td::before { content: attr(data-label); color: var(--text-secondary); font-size: .75rem; margin-right: 8px; flex-shrink: 0; }

    /* Card kanan di detail — full width */
    .detail-sidebar-col { order: -1; }

    /* Summary keuangan in detail */
    .keuangan-summary td { font-size: .82rem; }
}

/* ---- Extra Utilities ---- */
.btn-xs {
    padding: 2px 8px;
    font-size: 0.75rem;
    border-radius: 4px;
    line-height: 1.5;
}

.btn-outline-navy {
    color: var(--navy);
    border-color: var(--navy);
}
.btn-outline-navy:hover {
    background: var(--navy);
    color: #fff;
}

.border-navy { border-color: var(--navy) !important; }

/* Table compact */
.table > :not(caption) > * > * { padding: 0.5rem 0.75rem; }

/* Card hover clickable */
tr[onclick] { cursor: pointer; }

/* ============================================================
   LOGADM SIDEBAR — sidebar-link (bukan nav-link, agar tidak
   bentrok dengan Bootstrap .nav-link)
   ============================================================ */
.admin-sidebar {
    background: var(--navy);
}

.admin-sidebar .sidebar-brand {
    padding: 18px 20px;
    background: rgba(0,0,0,0.25);
    border-bottom: 1px solid rgba(255,255,255,0.12);
    min-height: var(--topbar-height);
    display: flex;
    align-items: center;
}

.admin-sidebar .brand-text {
    color: #ffffff;
    font-weight: 700;
    font-size: 1.2rem;
    display: block;
}

.admin-sidebar .brand-tagline {
    color: #2ECC8A;
    font-size: 0.7rem;
    font-weight: 500;
    display: block;
}

.admin-sidebar .sidebar-menu {
    padding: 12px 0;
    flex: 1;
}

.admin-sidebar .menu-label {
    color: rgba(255,255,255,0.45);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    padding: 10px 20px 4px;
    display: block;
}

/* ---- sidebar-link: class khusus menggantikan nav-link ---- */
.admin-sidebar a.sidebar-link {
    color: #e2e8f0;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-left: 3px solid transparent;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
}

.admin-sidebar a.sidebar-link i {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    color: rgba(255,255,255,0.65);
    flex-shrink: 0;
    transition: color 0.2s;
}

.admin-sidebar a.sidebar-link:hover {
    color: #ffffff;
    background: rgba(255,255,255,0.10);
    border-left-color: #2ECC8A;
    text-decoration: none;
}

.admin-sidebar a.sidebar-link:hover i {
    color: #2ECC8A;
}

.admin-sidebar a.sidebar-link.active {
    color: #ffffff;
    background: rgba(46,204,138,0.18);
    border-left-color: #2ECC8A;
    font-weight: 600;
}

.admin-sidebar a.sidebar-link.active i {
    color: #2ECC8A;
}

/* Footer sidebar */
.admin-sidebar .sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    background: rgba(0,0,0,0.2);
}

.admin-sidebar .sidebar-footer .user-info .fw-600 {
    color: #ffffff;
}

.admin-sidebar .sidebar-footer .user-role {
    color: rgba(255,255,255,0.6);
    font-size: 0.78rem;
}

/* Admin topbar */
.admin-main #topbar {
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

/* ---- Card Header Tabs ---- */
.card-header-tabs {
    margin-bottom: -1px;
    border-bottom: none;
}
.card-header-tabs .nav-link {
    color: var(--text-secondary);
    font-size: .82rem;
    padding: 4px 12px;
    border-radius: 6px 6px 0 0;
}
.card-header-tabs .nav-link.active {
    color: var(--navy);
    font-weight: 600;
    background: #fff;
    border: 1px solid var(--border);
    border-bottom-color: #fff;
}
.card-header-tabs .nav-link:hover {
    color: var(--navy);
    background: rgba(26,58,110,.05);
}

/* ---- Card Header Nav Tabs (tab aktif = bg sama dengan thead tabel) ---- */
.card-header .nav-tabs {
    border-bottom: none;
}
.card-header .nav-tabs .nav-link {
    color: var(--text-secondary);
    font-size: .85rem;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    padding: 10px 16px;
}
.card-header .nav-tabs .nav-link.active {
    color: var(--navy) !important;
    font-weight: 600;
    background-color: var(--bg-light) !important;
    border-color: transparent !important;
    border-bottom: 2px solid var(--navy) !important;
}
.card-header .nav-tabs .nav-link:hover:not(.active) {
    color: var(--navy);
    background: rgba(26,58,110,.04);
}

/* Admin topbar */
.admin-main #topbar {
    margin-left: 0;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

/* ============================================================
   MOBILE ENHANCEMENTS — applied on top of existing styles
   ============================================================ */

/* ── Sidebar overlay backdrop ──────────────────────────────── */
#sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 999;
    cursor: pointer;
}
@media (max-width: 992px) {
    #sidebar.show ~ #sidebar-overlay,
    #sidebar-overlay.show {
        display: block;
    }
}

/* ── Topbar mobile refinements ─────────────────────────────── */
@media (max-width: 576px) {
    #topbar {
        padding: 0 12px;
        gap: 8px;
    }
    #topbar .page-title {
        font-size: .85rem;
        flex: 1;           /* pastikan tetap mengisi ruang tengah */
        min-width: 0;      /* izinkan shrink */
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    /* Right items selalu di ujung kanan */
    #topbar > .d-flex:last-child {
        margin-left: auto;
        flex-shrink: 0;
    }
}

/* ── KPI cards: value font shrink on small screens ─────────── */
@media (max-width: 400px) {
    .kpi-card .kpi-value {
        font-size: 1rem !important;
    }
    .kpi-card .kpi-label {
        font-size: .72rem;
    }
    .kpi-card .kpi-icon {
        width: 32px;
        height: 32px;
        font-size: .9rem;
    }
    .kpi-card {
        padding: 8px 10px;
    }
}

/* ── Card header forms: flex wrap on narrow screens ───────── */
@media (max-width: 767px) {
    .card-header .d-flex.gap-2.flex-wrap,
    .card-header form.d-flex {
        flex-wrap: wrap;
        gap: 6px;
    }
    .card-header form .form-control,
    .card-header form .form-select {
        min-width: 0;
        max-width: 100% !important;
        flex: 1 1 140px;
    }
}

/* ── Modal: near-full-screen on phones ────────────────────── */
@media (max-width: 575px) {
    .modal-dialog {
        margin: 8px;
        max-width: calc(100vw - 16px);
    }
    .modal-dialog.modal-lg,
    .modal-dialog.modal-xl {
        max-width: calc(100vw - 16px);
    }
    .modal-body { padding: 12px; }
}

/* ── Alert trial/expired: stack on mobile ──────────────────── */
@media (max-width: 575px) {
    .alert-trial,
    .alert-expired .d-flex {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 8px;
    }
    .alert-trial .btn,
    .alert-expired .btn { width: 100%; text-align: center; }
}

/* ── Tab nav horizontal scroll ─────────────────────────────── */
@media (max-width: 767px) {
    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: visible;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .nav-tabs::-webkit-scrollbar { display: none; }
    .nav-tabs .nav-link {
        white-space: nowrap;
        font-size: .82rem;
        padding: 8px 12px;
    }
    /* card-header yang punya p-0 + border-radius: pastikan tidak clip konten tab */
    .card-header {
        overflow: visible !important;
    }
    /* kurangi padding nav-link di card-header pada mobile agar tidak muncul scrollbar vertikal */
    .card-header .nav-tabs .nav-link {
        padding: 8px 14px;
        font-size: .82rem;
    }
}

/* ── Production timeline: horizontal scroll ────────────────── */
.production-timeline {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap !important;
    padding-bottom: 4px;
    scrollbar-width: none;
}
.production-timeline::-webkit-scrollbar { display: none; }

@media (max-width: 767px) {
    .timeline-step {
        white-space: nowrap;
        font-size: .72rem;
        padding: 3px 8px;
    }
}

/* ── Detail pages: action buttons wrap + full width on phones ─ */
@media (max-width: 575px) {
    /* SO detail & produksi detail header buttons */
    .d-flex.gap-2.flex-wrap > .btn {
        font-size: .8rem;
        padding: 5px 10px;
    }
    /* sticky card on right column: remove sticky on mobile */
    .sticky-lg-top { position: static !important; }
}

/* ── Pagination on mobile: compact ────────────────────────── */
@media (max-width: 575px) {
    .pagination { flex-wrap: wrap; gap: 2px; }
    .page-link { padding: 4px 8px; font-size: .8rem; }
}

/* ── Form rows: single column on mobile ───────────────────── */
@media (max-width: 575px) {
    .row.g-3 > [class*="col-md-"],
    .row.g-4 > [class*="col-md-"] {
        /* Bootstrap col-12 on xs is already default, this is a safety net */
    }
    /* Form sections padding */
    .content-area .card .card-body {
        padding: 12px;
    }
}

/* ── Table in detail pages: scrollable ────────────────────── */
@media (max-width: 767px) {
    .card .table-responsive {
        border-radius: 0;
    }
    /* Card body: konten yang lebih lebar dari layar bisa discroll horizontal */
    .card-body-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    /* Card mengikuti lebar browser — tidak boleh overflow ke kanan */
    .card {
        max-width: 100%;
        box-sizing: border-box;
    }
    /* Card-body: konten lebih lebar → scroll horizontal di dalam card */
    .card > .card-body,
    .card > .card-body > .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ── Toast container: full width on mobile ────────────────── */
@media (max-width: 575px) {
    #toast-container {
        left: 8px;
        right: 8px;
        top: 12px;
        max-width: none;
    }
    .toast-item { font-size: .82rem; }
}

/* ── Dropdown menus: prevent overflow off screen ───────────── */
@media (max-width: 575px) {
    .dropdown-menu {
        max-width: calc(100vw - 24px);
    }
}

/* ── Filter button groups: wrap ────────────────────────────── */
@media (max-width: 575px) {
    .mb-3.d-flex.gap-2 {
        flex-wrap: wrap;
    }
    .mb-3.d-flex.gap-2 .btn {
        font-size: .78rem;
        padding: 4px 10px;
    }
}

/* ── Auth pages: padding on mobile ─────────────────────────── */
@media (max-width: 575px) {
    .auth-card, .card.shadow { margin: 8px; }
}
