/* ============================================================
   WARUNG SEMBAKO IBU ANI - Custom CSS
   Menggunakan Bootstrap 5 sebagai fondasi
   ============================================================ */

/* --- Google Font: Inter --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ============================================================
   CSS VARIABLES (Design Tokens)
   ============================================================ */
:root {
    /* Warna Primer (Admin - Biru Tua Indigo) */
    --primary:          #4f46e5;
    --primary-dark:     #3730a3;
    --primary-light:    #818cf8;
    --primary-bg:       #eef2ff;

    /* Warna Sekunder (Karyawan - Hijau Teal) */
    --secondary:        #059669;
    --secondary-dark:   #047857;
    --secondary-light:  #34d399;
    --secondary-bg:     #ecfdf5;

    /* Warna Status */
    --danger:           #ef4444;
    --warning:          #f59e0b;
    --info:             #3b82f6;
    --success:          #10b981;

    /* Warna Sidebar */
    --sidebar-bg:       #0f172a;
    --sidebar-width:    260px;
    --sidebar-link:     #94a3b8;
    --sidebar-hover:    #1e293b;
    --sidebar-active:   #4f46e5;

    /* Warna Topbar */
    --topbar-bg:        #1e1b4b;
    --topbar-karyawan:  #064e3b;

    /* Warna Latar */
    --body-bg:          #f1f5f9;
    --card-bg:          #ffffff;
    --border-color:     #e2e8f0;

    /* Teks */
    --text-primary:     #0f172a;
    --text-secondary:   #64748b;
    --text-muted:       #94a3b8;

    /* Shadow */
    --shadow-sm:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
    --shadow-md:        0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --shadow-lg:        0 10px 15px rgba(0,0,0,.08), 0 4px 6px rgba(0,0,0,.05);

    /* Border Radius */
    --radius-sm:        6px;
    --radius-md:        10px;
    --radius-lg:        16px;
    --radius-xl:        24px;

    /* Topbar Height */
    --topbar-h:         62px;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--body-bg);
    color: var(--text-primary);
    font-size: 0.9rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============================================================
   TOP NAVIGATION BAR
   ============================================================ */
.topbar {
    background: linear-gradient(135deg, var(--topbar-bg) 0%, #312e81 100%);
    height: var(--topbar-h);
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1040;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.topbar-karyawan {
    background: linear-gradient(135deg, var(--topbar-karyawan) 0%, #065f46 100%);
}

/* Brand Logo */
.brand-icon {
    width: 38px; height: 38px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(79,70,229,.4);
}

.brand-icon-karyawan {
    background: linear-gradient(135deg, var(--secondary), var(--secondary-light));
    box-shadow: 0 4px 10px rgba(5,150,105,.4);
}

.brand-text {
    display: flex; flex-direction: column; line-height: 1.2;
}

.brand-title {
    font-size: .95rem; font-weight: 700; color: #fff;
}

.brand-sub {
    font-size: .7rem; color: rgba(255,255,255,.6); font-weight: 400;
}

/* User Avatar */
.user-avatar {
    width: 34px; height: 34px;
    background: rgba(255,255,255,.15);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid rgba(255,255,255,.25);
    color: #fff;
}

/* Avatar variant untuk admin (ungu) */
.admin-avatar {
    background: rgba(79,70,229,.3);
    border-color: rgba(129,140,248,.5);
}

/* Avatar variant untuk karyawan (hijau) */
.karyawan-avatar {
    background: rgba(5,150,105,.3);
    border-color: rgba(52,211,153,.5);
}

/* ============================================================
   SIDEBAR NAVIGATION
   ============================================================ */
.wrapper {
    margin-top: var(--topbar-h);
    min-height: calc(100vh - var(--topbar-h) - 48px);
}

.sidebar-nav {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    min-height: calc(100vh - var(--topbar-h));
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: 0;
    overflow-y: auto;
    transition: transform .25s ease, box-shadow .25s ease;
    z-index: 1030;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255,255,255,.05);
}

/* Scrollbar sidebar */
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 10px; }

/* Sidebar Menu */
.sidebar-menu { padding: 12px 0; }

.sidebar-divider {
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .08em;
    color: #475569;
    padding: 16px 20px 6px;
    text-transform: uppercase;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--sidebar-link);
    text-decoration: none;
    font-size: .875rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all .2s ease;
    position: relative;
}

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

.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: #e2e8f0;
    text-decoration: none;
}

.sidebar-link.active {
    background: rgba(79,70,229,.15);
    color: var(--primary-light);
    border-left-color: var(--primary);
}

.sidebar-karyawan .sidebar-link.active {
    background: rgba(5,150,105,.15);
    color: var(--secondary-light);
    border-left-color: var(--secondary);
}

.text-danger-soft {
    color: #f87171 !important;
}

.text-danger-soft:hover {
    background: rgba(239,68,68,.1) !important;
    color: #fca5a5 !important;
}

/* Sidebar Footer */
.sidebar-footer {
    margin-top: auto;
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,.05);
}

/* Sidebar Overlay (Mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1025;
    backdrop-filter: blur(2px);
}

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

/* ============================================================
   MAIN CONTENT AREA
   ============================================================ */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: calc(100vh - var(--topbar-h));
    transition: margin-left .25s ease;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    background: var(--card-bg);
    transition: box-shadow .2s ease;
}

.card:hover { box-shadow: var(--shadow-md); }

.card-header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

/* STAT CARDS (Dashboard) */
.stat-card {
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    border: none;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
    transition: transform .25s ease, box-shadow .25s ease;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: -20px; right: -20px;
    width: 100px; height: 100px;
    background: rgba(255,255,255,.1);
    border-radius: 50%;
}

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

.stat-card-icon {
    width: 58px; height: 58px;
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem;
    background: rgba(255,255,255,.2);
    flex-shrink: 0;
    z-index: 1;
}

.stat-card-body { z-index: 1; }
.stat-card-label { font-size: .8rem; font-weight: 500; opacity: .85; margin-bottom: 4px; }
.stat-card-value { font-size: 1.65rem; font-weight: 800; line-height: 1; }
.stat-card-sub { font-size: .75rem; opacity: .75; margin-top: 4px; }

/* Card Warna */
.card-indigo  { background: linear-gradient(135deg, #4f46e5, #7c3aed); color: #fff; }
.card-teal    { background: linear-gradient(135deg, #0891b2, #0e7490); color: #fff; }
.card-emerald { background: linear-gradient(135deg, #059669, #047857); color: #fff; }
.card-amber   { background: linear-gradient(135deg, #d97706, #b45309); color: #fff; }
.card-rose    { background: linear-gradient(135deg, #e11d48, #be123c); color: #fff; }

/* ============================================================
   TABEL
   ============================================================ */
.table-responsive { border-radius: var(--radius-md); overflow: hidden; }

.table {
    margin-bottom: 0;
    font-size: .875rem;
}

.table thead th {
    background: #f8fafc;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 2px solid var(--border-color);
    padding: .85rem 1rem;
    white-space: nowrap;
}

.table tbody td {
    padding: .8rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text-primary);
}

.table tbody tr:hover td { background: #f8fafc; }
.table tbody tr:last-child td { border-bottom: none; }

/* ============================================================
   BADGES
   ============================================================ */
.badge { font-weight: 500; font-size: .72rem; padding: .35em .7em; }

.badge-stok-ok   { background: #dcfce7; color: #166534; }
.badge-stok-warn { background: #fef9c3; color: #854d0e; }
.badge-stok-low  { background: #fee2e2; color: #991b1b; }

/* ============================================================
   FORM & INPUT
   ============================================================ */
.form-control, .form-select {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: .875rem;
    padding: .55rem .85rem;
    transition: border-color .2s, box-shadow .2s;
    background: #fff;
    color: var(--text-primary);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.15);
}

.form-label {
    font-weight: 500;
    font-size: .825rem;
    color: var(--text-secondary);
    margin-bottom: .4rem;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    font-weight: 500;
    font-size: .875rem;
    border-radius: var(--radius-sm);
    transition: all .2s ease;
    padding: .5rem 1rem;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79,70,229,.3);
}

.btn-success:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16,185,129,.3);
}

.btn-danger:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239,68,68,.3);
}

.btn-sm { padding: .35rem .75rem; font-size: .8rem; }

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.page-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: .6rem;
}

.page-title i { color: var(--primary); }

.page-subtitle {
    font-size: .825rem;
    color: var(--text-secondary);
    margin: .2rem 0 0;
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
    border: none;
    border-radius: var(--radius-md);
    font-size: .875rem;
    font-weight: 500;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-content {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px rgba(0,0,0,.15);
}

.modal-header {
    background: linear-gradient(135deg, var(--primary), #6d28d9);
    color: #fff;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 1.25rem 1.5rem;
}

.modal-header .btn-close { filter: invert(1); }
.modal-header.bg-danger-gradient {
    background: linear-gradient(135deg, var(--danger), #b91c1c);
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
    min-height: 100vh;
    background: linear-gradient(rgba(15, 23, 42, 0.7), rgba(15, 23, 42, 0.8)), url('../img/bg-login.jpg') center/cover no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    position: relative;
    overflow: hidden;
}

/* Dekorasi Latar Belakang Login */
.login-page::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(79,70,229,.3), transparent 70%);
    top: -200px; left: -200px;
    border-radius: 50%;
}

.login-page::after {
    content: '';
    position: absolute;
    width: 500px; height: 500px;
    background: radial-gradient(circle, rgba(5,150,105,.2), transparent 70%);
    bottom: -150px; right: -150px;
    border-radius: 50%;
}

.login-card {
    background: rgba(255,255,255,.97);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 60px rgba(0,0,0,.35);
    position: relative;
    z-index: 10;
    backdrop-filter: blur(10px);
}

.login-logo {
    width: 70px; height: 70px;
    background: linear-gradient(135deg, var(--primary), #6d28d9);
    border-radius: var(--radius-lg);
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem; color: #fff;
    margin: 0 auto 1.25rem;
    box-shadow: 0 8px 25px rgba(79,70,229,.4);
}

.login-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: .25rem;
    text-align: center;
}

.login-subtitle {
    font-size: .825rem;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 2rem;
}

.login-card .form-control {
    padding: .65rem 1rem;
    font-size: .9rem;
}

.input-icon-wrap {
    position: relative;
}

.input-icon-wrap .input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    z-index: 5;
}

.input-icon-wrap .form-control {
    padding-left: 2.5rem;
}

/* ============================================================
   CHART WRAPPER
   ============================================================ */
.chart-container {
    position: relative;
    height: 280px;
    width: 100%;
}

/* ============================================================
   STOK INDICATOR
   ============================================================ */
.stok-bar {
    height: 6px;
    border-radius: 3px;
    background: #e2e8f0;
    overflow: hidden;
    margin-top: 4px;
}

.stok-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width .5s ease;
}

/* ============================================================
   TRANSAKSI ITEM (Kasir / POS)
   ============================================================ */
.kasir-panel {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.kasir-header {
    background: linear-gradient(135deg, var(--primary), #6d28d9);
    color: #fff;
    padding: 1.25rem;
}

.item-cart {
    border-bottom: 1px solid var(--border-color);
    padding: .75rem 1rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    transition: background .15s;
}

.item-cart:hover { background: #f8fafc; }
.item-cart:last-child { border-bottom: none; }

.item-cart-name { font-weight: 600; font-size: .875rem; }
.item-cart-price { color: var(--text-secondary); font-size: .8rem; }

/* ============================================================
   FOOTER
   ============================================================ */
.app-footer {
    background: #fff;
    border-top: 1px solid var(--border-color);
    margin-left: var(--sidebar-width);
    margin-top: auto;
    transition: margin-left .25s ease;
}

/* Footer di halaman login (tanpa sidebar) */
.login-page + .app-footer,
body.no-sidebar .app-footer {
    margin-left: 0;
}

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination .page-link {
    border-radius: var(--radius-sm) !important;
    margin: 0 2px;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: .825rem;
}

.pagination .page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
}

/* ============================================================
   SEARCH & FILTER BAR
   ============================================================ */
.filter-bar {
    background: #fff;
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .75rem;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 3.5rem;
    color: var(--border-color);
    display: block;
    margin-bottom: 1rem;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 991.98px) {
    .sidebar-nav {
        transform: translateX(-100%);
        box-shadow: none;
    }

    .sidebar-nav.show {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0,0,0,.3);
    }

    .main-content { margin-left: 0 !important; }
    .app-footer   { margin-left: 0 !important; }

    .stat-card-value { font-size: 1.4rem; }
}

@media (max-width: 575.98px) {
    .login-card { padding: 1.75rem 1.25rem; }
    .stat-card  { padding: 1.1rem; gap: 1rem; }
    .stat-card-icon { width: 48px; height: 48px; font-size: 1.3rem; }
    .page-header { flex-direction: column; }
    .filter-bar  { flex-direction: column; align-items: stretch; }
}

/* ============================================================
   TAMBAHAN FITUR: THUMBNAIL BARANG & STRUK
   ============================================================ */
/* Image Thumbnail */
.product-thumb {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    object-fit: cover;
    background-color: var(--body-bg);
    border: 1px solid var(--border-color);
}

.product-img-card {
    width: 100%;
    height: 160px;
    object-fit: cover;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    border-bottom: 1px solid var(--border-color);
}

.product-grid-item {
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--card-bg);
}

.product-grid-item:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

/* Print Styles untuk Cetak Struk */
@media print {
    body {
        margin: 0;
        padding: 0;
        background: white;
        font-family: monospace, sans-serif;
    }
    .no-print {
        display: none !important;
    }
    .print-only {
        display: block !important;
    }
    .struk-container {
        width: 100% !important;
        max-width: 80mm !important;
        margin: 0 auto !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: none !important;
    }
}
.struk-container {
    width: 80mm;
    margin: 2rem auto;
    background: #fff;
    padding: 1rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    line-height: 1.2;
    color: #000;
}
.struk-header {
    text-align: center;
    border-bottom: 1px dashed #000;
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
}
.struk-table {
    width: 100%;
}
.struk-table th, .struk-table td {
    padding: 2px 0;
    text-align: right;
}
.struk-table th:first-child, .struk-table td:first-child {
    text-align: left;
}
.struk-footer {
    text-align: center;
    border-top: 1px dashed #000;
    padding-top: 0.5rem;
    margin-top: 0.5rem;
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.fw-600    { font-weight: 600; }
.fw-700    { font-weight: 700; }
.fw-800    { font-weight: 800; }
.fw-900    { font-weight: 900; }
.text-xs   { font-size: .75rem; }
.text-sm   { font-size: .825rem; }
.rounded-lg { border-radius: var(--radius-lg) !important; }
.gap-2     { gap: .5rem; }
.gap-3     { gap: .75rem; }
.shadow-md { box-shadow: var(--shadow-md) !important; }

/* Text clamp (truncate baris ke-N) */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.line-clamp-1 {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
