/* =========================================================
   CRM RAK TOKO - STYLESHEET UTAMA
   ========================================================= */

:root {
    --sidebar-width: 250px;
    --brand-color: #2563eb;
    --brand-dark: #1e3a8a;
    --bg-body: #f4f6fb;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --radius: 12px;
}

* { box-sizing: border-box; }

body {
    background-color: var(--bg-body);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: #1f2937;
    margin: 0;
}

a { text-decoration: none; }

/* ============ LOGIN PAGE ============ */
.login-page {
    background: linear-gradient(135deg, var(--brand-dark), var(--brand-color));
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-wrapper { width: 100%; padding: 20px; }
.login-card {
    background: #fff;
    max-width: 400px;
    margin: 0 auto;
    padding: 36px 32px;
    border-radius: var(--radius);
    box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand i { font-size: 40px; color: var(--brand-color); }
.login-brand h4 { margin: 8px 0 2px; font-weight: 700; }

/* ============ APP LAYOUT ============ */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--brand-dark), #0f172a);
    color: #fff;
    flex-shrink: 0;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 1000;
    transition: transform .25s ease;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 22px 20px;
    font-weight: 700;
    font-size: 17px;
    border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-brand i { font-size: 22px; color: #60a5fa; }

.sidebar-menu { padding: 10px 12px; }
.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    margin-bottom: 2px;
    border-radius: 8px;
    color: rgba(255,255,255,.75);
    font-size: 14px;
    transition: background .15s;
}
.menu-item i { font-size: 16px; width: 18px; text-align: center; }
.menu-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.menu-item.active { background: var(--brand-color); color: #fff; font-weight: 600; }
.menu-item.disabled { opacity: .45; cursor: not-allowed; }
.menu-item .badge { font-size: 10px; }

.app-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 900;
}
.page-title { font-weight: 700; flex: 1; }
.btn-toggle-sidebar { border: none; background: none; font-size: 22px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.user-avatar {
    width: 36px; height: 36px;
    background: var(--brand-color);
    color: #fff;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.page-content { padding: 24px; }

/* ============ CARD & WIDGET ============ */
.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border-color);
    height: 100%;
    position: relative;
    overflow: hidden;
}
.stat-card .stat-icon {
    width: 46px; height: 46px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 12px;
}
.stat-card .stat-value { font-size: 26px; font-weight: 800; margin: 0; }
.stat-card .stat-label { color: var(--text-muted); font-size: 13px; margin: 0; }

.bg-soft-primary { background: #dbeafe; color: #1d4ed8; }
.bg-soft-success { background: #dcfce7; color: #15803d; }
.bg-soft-warning { background: #fef3c7; color: #b45309; }
.bg-soft-danger  { background: #fee2e2; color: #b91c1c; }
.bg-soft-info    { background: #e0f2fe; color: #0369a1; }
.bg-soft-purple  { background: #ede9fe; color: #6d28d9; }

.chart-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
}
.chart-card h6 { font-weight: 700; margin-bottom: 4px; }
.chart-card .chart-sub { color: var(--text-muted); font-size: 12px; margin-bottom: 16px; }

.badge-coming-soon {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 250px;
    color: var(--text-muted);
    flex-direction: column;
    gap: 8px;
}

/* ============ TABLE ============ */
.table-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border-color);
}

/* ============ MODUL PRODUK ============ */
.produk-thumb {
    width: 44px; height: 44px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: #f4f6fb;
}
.produk-thumb-placeholder {
    width: 44px; height: 44px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: #f4f6fb;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #c3c9d4;
    font-size: 18px;
}
.produk-foto-preview {
    width: 100%;
    max-width: 260px;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background: #f4f6fb;
}
.produk-foto-preview-placeholder {
    width: 100%;
    max-width: 260px;
    aspect-ratio: 1 / 1;
    border-radius: var(--radius);
    border: 1px dashed var(--border-color);
    background: #f4f6fb;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #c3c9d4;
    font-size: 42px;
}

/* ============ MODUL LAYOUT TOKO ============ */
.layout-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 16px;
}
.layout-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.layout-card img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    display: block;
    background: #f4f6fb;
}
.layout-card-placeholder {
    width: 100%;
    aspect-ratio: 4 / 3;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f4f6fb;
    color: #c3c9d4;
    font-size: 36px;
}
.layout-card-body { padding: 12px 14px; flex: 1; display: flex; flex-direction: column; }
.layout-card-body h6 { margin: 0 0 4px; font-weight: 700; }
.layout-card-actions { padding: 0 14px 14px; display: flex; gap: 6px; }

/* ============ MODUL PEMBAYARAN ============ */
.progress-bayar { height: 8px; border-radius: 4px; background: #e5e7eb; overflow: hidden; }
.progress-bayar > div { height: 100%; background: #15803d; }

/* ============ MODUL DOKUMEN ============ */
.doc-icon-lg { font-size: 26px; width: 42px; text-align: center; }

/* ============ RESPONSIVE ============ */
@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .app-content { margin-left: 0; }
}

/* ============ CETAK (PRINT) ============ */
/* Berlaku di semua halaman: saat window.print() dipanggil, sidebar & topbar
   disembunyikan supaya yang tercetak hanya konten utama (bilah kanan). */
@media print {
    @page {
        margin: 1.5cm;
    }
    .sidebar,
    .topbar,
    .btn-toggle-sidebar {
        display: none !important;
    }
    .app-content {
        margin-left: 0 !important;
        width: 100% !important;
    }
    .page-content {
        padding: 12px !important;
    }
}