:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #475569;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --sidebar-bg: #1e293b;
    --sidebar-width: 250px;
    --topbar-height: 56px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    overflow-x: hidden;
    margin: 0;
}

/* ===========================
   SIDEBAR — always position:fixed
=========================== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--sidebar-bg);
    color: #f8fafc;
    z-index: 1045;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.sidebar .nav-link {
    color: #cbd5e1 !important;
    border-radius: 0.375rem;
    padding: 0.6rem 0.875rem;
    margin: 0.15rem 0.625rem;
    font-weight: 500;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    transition: all 0.15s ease;
    white-space: nowrap;
    text-decoration: none;
}
.sidebar .nav-link i {
    font-size: 1rem;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}
.sidebar .nav-link:hover {
    background-color: rgba(255,255,255,.08);
    color: #ffffff !important;
}
.sidebar .nav-link.active {
    background-color: var(--primary-color) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 6px -1px rgba(37,99,235,.3);
}

/* ===========================
   SIDEBAR OVERLAY (mobile)
=========================== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 1040;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ===========================
   MOBILE TOPBAR
=========================== */
.mobile-topbar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    z-index: 1030;
    background: var(--sidebar-bg);
    color: #fff;
    align-items: center;
    padding: 0 1rem;
    gap: 0.875rem;
    box-shadow: 0 2px 12px rgba(0,0,0,.2);
}
.mobile-topbar .topbar-brand {
    flex: 1;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: -0.01em;
}
.mobile-topbar .topbar-sub {
    font-size: 0.75rem;
    color: rgba(255,255,255,.5);
}
.hamburger-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.375rem;
    transition: background 0.15s ease;
}
.hamburger-btn:hover {
    background: rgba(255,255,255,.1);
}

/* ===========================
   MAIN CONTENT
=========================== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    padding: 1.75rem 2rem;
    background-color: var(--bg-color);
}

/* ===========================
   CARDS
=========================== */
.glass-card, .card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.03);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.glass-card:hover, .card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
}

/* ===========================
   FORMS
=========================== */
.form-control, .form-select {
    background-color: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 0.5rem !important;
    color: var(--text-main) !important;
    font-size: 0.875rem !important;
    padding: 0.5rem 0.75rem !important;
    box-shadow: none !important;
    transition: border-color 0.15s ease, box-shadow 0.15s ease !important;
    width: 100%;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 3px rgba(37,99,235,.15) !important;
    outline: 0 !important;
}
.input-group-text {
    background-color: #f1f5f9 !important;
    border: 1px solid #cbd5e1 !important;
    color: var(--text-muted) !important;
}

/* ===========================
   BUTTONS
=========================== */
.btn {
    border-radius: 0.5rem !important;
    font-weight: 500 !important;
    padding: 0.5rem 1rem !important;
    transition: all 0.15s ease !important;
    white-space: nowrap;
}
.btn-primary {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: #ffffff !important;
}
.btn-primary:hover {
    background-color: var(--primary-hover) !important;
    border-color: var(--primary-hover) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(37,99,235,.25) !important;
}
.btn-outline-primary {
    color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}
.btn-outline-primary:hover {
    background-color: var(--primary-color) !important;
    color: #ffffff !important;
}
.btn-sm {
    padding: 0.3rem 0.65rem !important;
    font-size: 0.8rem !important;
}

/* ===========================
   TABLES
=========================== */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
}
.table-custom {
    background-color: #ffffff !important;
    margin-bottom: 0 !important;
    border-collapse: collapse;
    min-width: 550px;
    width: 100%;
}
.table-custom thead th {
    background-color: #f1f5f9 !important;
    border-bottom: 1px solid var(--border-color) !important;
    color: var(--secondary-color) !important;
    font-weight: 600 !important;
    text-transform: uppercase;
    font-size: 0.7rem !important;
    letter-spacing: 0.05em;
    padding: 0.75rem 1rem !important;
    white-space: nowrap;
}
.table-custom tbody td {
    padding: 0.875rem 1rem !important;
    border-bottom: 1px solid var(--border-color) !important;
    vertical-align: middle;
    font-size: 0.875rem;
}
.table-custom tbody tr:last-child td { border-bottom: none !important; }
.table-custom tbody tr { transition: background-color 0.1s ease; }
.table-custom tbody tr:hover { background-color: #f8fafc !important; }

/* ===========================
   BADGES
=========================== */
.badge {
    font-weight: 600 !important;
    padding: 0.35em 0.65em !important;
    border-radius: 0.375rem !important;
    font-size: 0.75rem !important;
}

/* ===========================
   MODALS
=========================== */
.modal-content {
    background-color: #ffffff !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 0.75rem !important;
    box-shadow: 0 20px 40px rgba(0,0,0,.12) !important;
}

/* ===========================
   RECEIPT
=========================== */
.receipt-container {
    background: #ffffff;
    padding: 24px;
    max-width: 450px;
    margin: 0 auto;
    font-family: 'Courier New', Courier, monospace;
    color: #1e293b;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
}
.receipt-header {
    text-align: center;
    border-bottom: 2px dashed #cbd5e1;
    padding-bottom: 12px;
    margin-bottom: 16px;
}
.receipt-divider { border-top: 1px dashed #cbd5e1; margin: 12px 0; }

/* ===========================
   TRACKING TIMELINE
=========================== */
.tracking-timeline {
    position: relative;
    padding: 1.5rem 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.timeline-inner { min-width: 480px; position: relative; }
.timeline-step { text-align: center; position: relative; z-index: 1; }
.timeline-icon {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #cbd5e1;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 0.75rem;
    font-size: 1.25rem;
    color: var(--text-muted);
    transition: all 0.2s ease;
}
.timeline-step.active .timeline-icon {
    border-color: var(--primary-color);
    color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(37,99,235,.1);
}
.timeline-step.completed .timeline-icon {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}
.timeline-line {
    position: absolute; top: 36px; left: 8%; right: 8%;
    height: 2px; background: #cbd5e1; z-index: 0;
}
.timeline-progress {
    position: absolute; top: 36px; left: 8%;
    height: 2px; background: var(--primary-color); z-index: 0;
    transition: width 0.3s ease;
}

/* ===========================
   UTILITIES
=========================== */
.text-gradient {
    background: linear-gradient(135deg, var(--primary-color), #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeInUp 0.35s ease forwards; }

/* ===========================
   DESKTOP (≥ 992px) — sidebar visible
=========================== */
@media (min-width: 992px) {
    .mobile-topbar { display: none !important; }
    .sidebar { transform: translateX(0) !important; }
    .sidebar-overlay { display: none !important; }
    .main-content { margin-left: var(--sidebar-width); padding-top: 1.75rem; }
}

/* ===========================
   MOBILE (< 992px) — sidebar hidden, topbar visible
=========================== */
@media (max-width: 991.98px) {
    .mobile-topbar { display: flex !important; }

    .sidebar {
        transform: translateX(-100%);
        top: 0;
    }
    .sidebar.open {
        transform: translateX(0);
    }

    /* Main content: full width, offset for topbar */
    .main-content {
        margin-left: 0 !important;
        padding: var(--topbar-height) 1rem 1.5rem 1rem;
        padding-top: calc(var(--topbar-height) + 1.25rem);
        width: 100%;
        min-height: 100vh;
    }

    /* Page title */
    .main-content h2 { font-size: 1.3rem; }
    .main-content h4 { font-size: 1.1rem; }

    /* Top action bar (title + button) */
    .main-content .d-flex.justify-content-between {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    /* Stats grid: 2 kolom */
    .row .col-md-3 {
        flex: 0 0 50% !important;
        max-width: 50% !important;
    }
}

/* ===========================
   SMALL MOBILE (< 576px)
=========================== */
@media (max-width: 575.98px) {
    .main-content {
        padding: calc(var(--topbar-height) + 1rem) 0.75rem 1rem 0.75rem;
    }

    /* Stats: 1 kolom */
    .row .col-md-3 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    /* Form columns collapse */
    .row .col-md-6,
    .row .col-md-4,
    .row .col-lg-8,
    .row .col-lg-4 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    /* Card padding */
    .glass-card.p-4, .card.p-4 { padding: 1rem !important; }
    .glass-card.p-5, .card.p-5 { padding: 1.25rem !important; }

    /* Buttons full width on forms */
    .btn.btn-lg.w-100 { font-size: 1rem !important; padding: 0.75rem 1rem !important; }

    /* Modal full screen */
    .modal-dialog {
        margin: 0 !important;
        max-width: 100% !important;
        min-height: 100%;
    }
    .modal-content {
        border-radius: 0 !important;
        min-height: 100vh;
    }

    /* Timeline smaller */
    .timeline-icon { width: 36px; height: 36px; font-size: 1rem; }
    .timeline-step span { font-size: 0.7rem; }

    /* Navbar buttons (index.php) */
    .navbar .btn {
        padding: 0.35rem 0.75rem !important;
        font-size: 0.8rem !important;
    }

    /* Hero search (index.php) */
    .hero-search-form {
        flex-direction: column !important;
        border-radius: 1rem !important;
        padding: 0.75rem !important;
        gap: 0.5rem;
    }
    .hero-search-form input { border-radius: 0.5rem !important; }
    .hero-search-form button {
        border-radius: 0.5rem !important;
        width: 100%;
    }

    /* Action buttons in table */
    .table-custom td .btn-sm {
        padding: 0.25rem 0.5rem !important;
        font-size: 0.7rem !important;
    }

    /* Login/register card */
    .glass-card { margin: 0 !important; }

    /* Receipt */
    .receipt-container { padding: 1rem; }
}
