/* ================================================================
   Kilat POS – Main Stylesheet
   Theme: Clean Blue & White | Dark/Light Mode
================================================================ */

/* ── Google Fonts ───────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&family=Fira+Code:wght@400;500&display=swap');

/* ── CSS Variables ──────────────────────────────────────────── */
:root {
    /* Brand */
    --primary:        #2563eb;
    --primary-dark:   #1d4ed8;
    --primary-light:  #eff6ff;
    --primary-subtle: #dbeafe;
    --accent:         #0ea5e9;

    /* Light Mode */
    --bg-body:        #f1f5f9;
    --bg-card:        #ffffff;
    --bg-sidebar:     #ffffff;
    --bg-navbar:      #ffffff;
    --bg-input:       #ffffff;
    --bg-hover:       #f8fafc;
    --bg-table-head:  #f8fafc;
    --bg-table-stripe:#fafafa;

    --text-primary:   #0f172a;
    --text-secondary: #475569;
    --text-muted:     #94a3b8;
    --text-sidebar:   #334155;

    --border:         #e2e8f0;
    --border-subtle:  #f1f5f9;

    --shadow-sm:      0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:      0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -1px rgba(0,0,0,.04);
    --shadow-lg:      0 10px 15px -3px rgba(0,0,0,.07), 0 4px 6px -2px rgba(0,0,0,.04);

    /* Sidebar */
    --sidebar-width:  240px;
    --navbar-height:  60px;

    /* Radius */
    --radius-sm:      6px;
    --radius-md:      10px;
    --radius-lg:      14px;

    /* Transitions */
    --transition:     all .2s ease;
}

/* ── Dark Mode ──────────────────────────────────────────────── */
[data-theme="dark"] {
    --bg-body:        #0f172a;
    --bg-card:        #1e293b;
    --bg-sidebar:     #1e293b;
    --bg-navbar:      #1e293b;
    --bg-input:       #0f172a;
    --bg-hover:       #334155;
    --bg-table-head:  #162032;
    --bg-table-stripe:#1a2840;

    --text-primary:   #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted:     #64748b;
    --text-sidebar:   #cbd5e1;

    --border:         #334155;
    --border-subtle:  #1e293b;

    --shadow-sm:      0 1px 3px rgba(0,0,0,.3);
    --shadow-md:      0 4px 6px -1px rgba(0,0,0,.3);
    --shadow-lg:      0 10px 15px -3px rgba(0,0,0,.3);
}

/* ── Base ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 14px; scroll-behavior: smooth; }

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    margin: 0;
    transition: background-color .3s, color .3s;
}

/* ── Layout ─────────────────────────────────────────────────── */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform .3s ease, width .25s ease, var(--transition);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    min-height: var(--navbar-height);
}

.sidebar-brand .brand-icon {
    width: 34px;
    height: 34px;
    background: var(--primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 16px;
    flex-shrink: 0;
}

.sidebar-brand .brand-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -.3px;
    line-height: 1.2;
}

.sidebar-brand .brand-name span {
    color: var(--primary);
}

.sidebar-brand .brand-version {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 400;
}

.sidebar-section {
    padding: 12px 12px 4px;
}

.sidebar-section-label {
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
    padding: 0 8px 6px;
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 8px;
    border-radius: var(--radius-sm);
    color: var(--text-sidebar);
    text-decoration: none;
    font-size: .82rem;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 2px;
    position: relative;
}

.sidebar-nav a i {
    width: 18px;
    text-align: center;
    font-size: .9rem;
    color: var(--text-muted);
    transition: var(--transition);
    flex-shrink: 0;
}

.sidebar-nav a:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.sidebar-nav a:hover i { color: var(--primary); }

.sidebar-nav a.active {
    background: var(--primary-subtle);
    color: var(--primary);
    font-weight: 600;
}

.sidebar-nav a.active i { color: var(--primary); }

.sidebar-nav a.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}

.sidebar-footer {
    margin-top: auto;
    padding: 12px;
    border-top: 1px solid var(--border);
}

/* ── Main Content ────────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left .3s ease;
}

/* ── Navbar ──────────────────────────────────────────────────── */
.top-navbar {
    height: var(--navbar-height);
    background: var(--bg-navbar);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 99;
    gap: 12px;
    box-shadow: var(--shadow-sm);
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-toggle {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-size: .85rem;
}

.sidebar-toggle:hover {
    background: var(--primary-light);
    border-color: var(--primary-subtle);
    color: var(--primary);
}

.page-title {
    font-size: .9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

/* Theme Toggle */
.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-size: .85rem;
}

.theme-toggle:hover {
    background: var(--primary-light);
    border-color: var(--primary-subtle);
    color: var(--primary);
}

/* User Dropdown */
.user-dropdown .dropdown-toggle {
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 5px 10px 5px 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.user-dropdown .dropdown-toggle::after { display: none; }

.user-dropdown .dropdown-toggle:hover {
    background: var(--primary-light);
    border-color: var(--primary-subtle);
}

.user-avatar {
    width: 28px;
    height: 28px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    flex-shrink: 0;
}

.user-name {
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-primary);
    max-width: 100px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: .65rem;
    color: var(--text-muted);
    line-height: 1;
}

.dropdown-menu {
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-md);
    padding: 6px;
    min-width: 180px;
}

.dropdown-item {
    color: var(--text-secondary);
    font-size: .8rem;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.dropdown-item:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.dropdown-item i { width: 14px; text-align: center; }

.dropdown-divider {
    border-color: var(--border);
    margin: 4px 0;
}

.dropdown-item.text-danger:hover {
    background: #fff1f2;
    color: #ef4444;
}

[data-theme="dark"] .dropdown-item.text-danger:hover {
    background: #3b0e0e;
}

/* ── Page Content ────────────────────────────────────────────── */
.page-content {
    padding: 22px;
    flex: 1;
}

.page-header {
    margin-bottom: 20px;
}

.page-header h1 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 2px;
}

.page-header p {
    font-size: .8rem;
    color: var(--text-muted);
    margin: 0;
}

/* ── Cards ───────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.card-header .card-title {
    font-size: .88rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.card-body { padding: 18px; }

/* ── Stat Cards ──────────────────────────────────────────────── */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 3px;
    height: 100%;
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}

.stat-card.blue::after  { background: var(--primary); }
.stat-card.sky::after   { background: var(--accent); }
.stat-card.green::after { background: #22c55e; }
.stat-card.amber::after { background: #f59e0b; }

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

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.stat-icon.blue  { background: #eff6ff; color: var(--primary); }
.stat-icon.sky   { background: #f0f9ff; color: var(--accent); }
.stat-icon.green { background: #f0fdf4; color: #22c55e; }
.stat-icon.amber { background: #fffbeb; color: #f59e0b; }

[data-theme="dark"] .stat-icon.blue  { background: #1e3a5f; }
[data-theme="dark"] .stat-icon.sky   { background: #0c2a3d; }
[data-theme="dark"] .stat-icon.green { background: #052e16; }
[data-theme="dark"] .stat-icon.amber { background: #2d1a00; }

.stat-info {}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 3px;
}

.stat-label {
    font-size: .75rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ── Tables ──────────────────────────────────────────────────── */
.table {
    color: var(--text-primary);
    margin: 0;
    font-size: .8rem;
}

.table thead th {
    background: var(--bg-table-head);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-color: var(--border);
    padding: 10px 14px;
    white-space: nowrap;
}

.table tbody td {
    border-color: var(--border-subtle);
    padding: 11px 14px;
    vertical-align: middle;
    color: var(--text-primary);
}

.table tbody tr:hover td {
    background: var(--bg-hover);
}

/* ── Forms ───────────────────────────────────────────────────── */
.form-label {
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.form-control, .form-select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    font-size: .82rem;
    padding: 8px 12px;
    transition: var(--transition);
}

.form-control:focus, .form-select:focus {
    background: var(--bg-input);
    border-color: var(--primary);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.form-control::placeholder { color: var(--text-muted); }

.input-group-text {
    background: var(--bg-hover);
    border-color: var(--border);
    color: var(--text-muted);
    font-size: .82rem;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
    font-size: .8rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    padding: 7px 14px;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

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

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

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

.btn-outline-primary:hover {
    background: var(--primary);
    color: #fff;
}

.btn-sm { padding: 5px 10px; font-size: .75rem; }

.btn-icon {
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
    font-size: .67rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
    letter-spacing: .02em;
}

.badge-owner  { background: #ede9fe; color: #6d28d9; }
.badge-admin  { background: #dbeafe; color: #1d4ed8; }
.badge-kasir  { background: #dcfce7; color: #15803d; }

[data-theme="dark"] .badge-owner  { background: #2e1065; color: #a78bfa; }
[data-theme="dark"] .badge-admin  { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .badge-kasir  { background: #052e16; color: #86efac; }

/* ── Alerts & Toasts ─────────────────────────────────────────── */
.toast-container { z-index: 9999; }

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-md);
    min-width: 280px;
}

.toast-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    font-size: .78rem;
    font-weight: 600;
}

.toast-body {
    font-size: .8rem;
    color: var(--text-secondary);
}

/* ── Modals ──────────────────────────────────────────────────── */
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.modal-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 14px 18px;
}

.modal-title {
    font-size: .9rem;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-body { padding: 18px; }

.modal-footer {
    border-top: 1px solid var(--border);
    padding: 12px 18px;
}

.btn-close {
    filter: none;
    opacity: .5;
}

[data-theme="dark"] .btn-close { filter: invert(1); }

/* ── Sidebar Collapsed (Desktop) ────────────────────────────── */
.sidebar {
    transition: width .25s ease, transform .3s ease, var(--transition);
}

.sidebar.collapsed {
    width: 60px !important;
    overflow-x: visible;
    overflow-y: visible;
}

.sidebar.collapsed .sidebar-brand .brand-name,
.sidebar.collapsed .sidebar-brand .brand-version,
.sidebar.collapsed .sidebar-section-label,
.sidebar.collapsed .sidebar-footer .flex-1 {
    display: none !important;
}

.sidebar.collapsed .sidebar-brand {
    justify-content: center;
    padding: 18px 10px;
}

.sidebar.collapsed .sidebar-section {
    padding: 10px 8px 4px;
}

.sidebar.collapsed .sidebar-nav a {
    justify-content: center;
    padding: 10px;
    overflow: visible;
}

/* Sembunyikan label teks, sisakan hanya ikon */
.sidebar.collapsed .sidebar-nav a span {
    display: none !important;
}

.sidebar.collapsed .sidebar-nav a i {
    width: auto;
    font-size: 1rem;
    margin: 0;
}

.sidebar.collapsed .sidebar-nav a.active::before {
    display: none;
}

.sidebar.collapsed .sidebar-footer > div {
    justify-content: center;
}

/* Tooltip saat collapsed */
.sidebar.collapsed .sidebar-nav a {
    position: relative;
}

.sidebar.collapsed .sidebar-nav a[data-label]:hover::after {
    content: attr(data-label);
    position: fixed;
    left: 68px;
    background: var(--text-primary);
    color: var(--bg-card);
    font-size: .72rem;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    z-index: 9999;
    pointer-events: none;
    box-shadow: var(--shadow-md);
}


.main-content.sidebar-collapsed {
    margin-left: 60px;
}

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

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

/* ── Login Page ──────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-body);
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 36px 32px;
}

.login-brand {
    text-align: center;
    margin-bottom: 28px;
}

.login-brand .brand-icon {
    width: 48px;
    height: 48px;
    background: var(--primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 22px;
    margin: 0 auto 12px;
}

.login-brand h1 {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 0 4px;
}

.login-brand h1 span { color: var(--primary); }

.login-brand p {
    font-size: .78rem;
    color: var(--text-muted);
    margin: 0;
}

/* ── Misc ────────────────────────────────────────────────────── */
.invalid-feedback { font-size: .75rem; }

.text-primary-custom { color: var(--primary) !important; }

.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 16px 0;
}

code {
    font-family: 'Fira Code', monospace;
    font-size: .78rem;
    background: var(--bg-hover);
    padding: 1px 6px;
    border-radius: 4px;
    color: var(--primary);
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

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

@media (max-width: 575.98px) {
    .page-content { padding: 14px; }
    .login-card { padding: 24px 18px; }
    .stat-value { font-size: 1.3rem; }
    .user-name, .user-role { display: none; }
}

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Animations ──────────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn .3s ease forwards;
}

.page-content .row > * {
    animation: fadeIn .3s ease both;
}

.page-content .row > *:nth-child(1) { animation-delay: .05s; }
.page-content .row > *:nth-child(2) { animation-delay: .10s; }
.page-content .row > *:nth-child(3) { animation-delay: .15s; }
.page-content .row > *:nth-child(4) { animation-delay: .20s; }

/* ── Loading Spinner ─────────────────────────────────────────── */
.btn .spinner-border-sm { width: .75rem; height: .75rem; border-width: 2px; }

/* ── Pagination ──────────────────────────────────────────────── */
.pagination {
    margin: 0;
    font-size: .78rem;
}

.page-link {
    background: var(--bg-card);
    border-color: var(--border);
    color: var(--text-secondary);
    padding: 5px 10px;
}

.page-link:hover {
    background: var(--primary-light);
    border-color: var(--primary-subtle);
    color: var(--primary);
}

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

.page-item.disabled .page-link {
    background: var(--bg-hover);
    color: var(--text-muted);
}
