:root {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-sidebar: #0f172a;
    --bg-sidebar-hover: #1e293b;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-light: #94a3b8;
    --border: #e2e8f0;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-sidebar: #020617;
    --bg-sidebar-hover: #0f172a;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-light: #64748b;
    --border: #334155;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 14px;
}

.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    color: #e2e8f0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    transition: all 0.3s ease;
    z-index: 100;
}

.sidebar-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1rem;
    font-weight: 700;
    color: white;
}

.logo i {
    width: 24px;
    height: 24px;
}

.sidebar-nav {
    padding: 1rem 0;
}

.nav-section {
    padding: 0.75rem 1.5rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin-top: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1.5rem;
    color: #cbd5e1;
    text-decoration: none;
    transition: all 0.2s ease;
    font-weight: 500;
}

.nav-link:hover {
    background: var(--bg-sidebar-hover);
    color: white;
}

.nav-link i {
    width: 18px;
    height: 18px;
}

.main-content {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0.875rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.375rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.breadcrumb {
    font-weight: 600;
    color: var(--text-primary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.theme-toggle {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    background: var(--border);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.375rem 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
}

.user-info {
    text-align: right;
}

.user-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.btn-logout {
    color: var(--danger);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.375rem;
}

.page-content {
    padding: 2rem;
    flex: 1;
}

.page-header {
    margin-bottom: 2rem;
}

.page-title {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.page-subtitle {
    color: var(--text-secondary);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.2s ease;
}

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

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.blue { background: rgba(37, 99, 235, 0.1); color: var(--primary); }
.stat-icon.green { background: rgba(34, 197, 94, 0.1); color: var(--success); }
.stat-icon.yellow { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.stat-icon.red { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.stat-icon.cyan { background: rgba(6, 182, 212, 0.1); color: var(--info); }

.stat-icon i {
    width: 24px;
    height: 24px;
}

.stat-info {
    flex: 1;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-primary);
}

.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.card-body {
    padding: 1.5rem;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
}

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: var(--bg-primary);
}

th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

tbody tr:hover {
    background: var(--bg-primary);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border: none;
    border-radius: 0.5rem;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

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

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

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.alert {
    padding: 1rem 1.25rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.alert-success {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-family: inherit;
 
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    padding: 1rem;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-secondary);
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
    overflow: hidden;
}

.login-header {
    padding: 2rem 2rem 1.5rem;
    text-align: center;
}

.login-logo {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.login-subtitle {
    color: var(--text-secondary);
}

.login-body {
    padding: 0 2rem 2rem;
}

.product-catalog-card {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    height: 100%;
    padding: 0;
    overflow: hidden;
    text-align: left;
    border: 1px solid var(--border);
    border-radius: 0.625rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.product-catalog-card:hover:not(:disabled) {
    transform: translateY(-2px);
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
}

.product-catalog-card:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.product-catalog-card .catalog-media {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: var(--bg-primary);
}

.product-catalog-card .catalog-media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-catalog-card .catalog-placeholder {
    display: flex;
    width: 100%;
    aspect-ratio: 4 / 3;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    color: var(--text-secondary);
}

.product-catalog-card .catalog-placeholder svg {
    width: 2rem;
    height: 2rem;
}

.product-catalog-card .catalog-price-bar {
    display: block;
    overflow: hidden;
    padding: 0.55rem 0.6rem;
    border-top: 1px solid var(--border);
    color: var(--primary);
    font-size: 0.9375rem;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
    text-overflow: ellipsis;
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.active {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .page-content {
        padding: 1rem;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

/* Kasir POS: transaksi kiri, katalog kanan */
.pos-layout {
    display: grid;
    grid-template-columns: 400px minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
}

.pos-layout > .card {
    margin-bottom: 0;
}

#catalogCard {
    scroll-margin-top: 5rem;
}

.catalog-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.catalog-page-size {
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
}

.pos-fullscreen-btn {
    padding: 0.4rem 0.7rem;
    border: 1px solid var(--border);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-weight: 600;
    white-space: nowrap;
}

.pos-fullscreen-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.pos-fullscreen-btn svg {
    width: 16px;
    height: 16px;
}

.catalog-meta {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.pos-catalog-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    margin-top: 0.75rem;
    align-items: stretch;
}

.catalog-empty {
    grid-column: 1 / -1;
    padding: 2rem 1rem;
    color: var(--text-secondary);
    text-align: center;
}

.catalog-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.catalog-page-info {
    min-width: 130px;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 600;
    text-align: center;
}

.catalog-pagination .btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.pos-cart-table {
    table-layout: fixed;
}

.pos-cart-table th,
.pos-cart-table td {
    padding: 0.5rem 0.35rem;
    vertical-align: middle;
}

.pos-cart-table th:first-child,
.pos-cart-table td:first-child {
    padding-left: 0;
}

.pos-cart-table th:last-child,
.pos-cart-table td:last-child {
    padding-right: 0;
}

.pos-cart-table th {
    font-size: 0.75rem;
}

.pos-cart-table td {
    font-size: 0.8125rem;
}

.pos-cart-table .cart-name {
    display: block;
    overflow: hidden;
    font-size: 0.8125rem;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.pos-cart-table .cart-code {
    display: block;
    overflow: hidden;
    color: var(--text-secondary);
    font-size: 0.6875rem;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.pos-cart-table .cart-qty-btn {
    min-width: 20px;
    justify-content: center;
    padding: 0.05rem 0.35rem;
    font-size: 0.75rem;
}

.pos-cart-table .cart-remove {
    padding: 0.1rem 0.4rem;
    font-size: 0.75rem;
}

/* Kartu kas kasir versi ringkas */
.cashier-cash-card .card-header {
    padding: 0.875rem 1.5rem;
}

.cashier-cash-card .card-body {
    padding: 1rem 1.5rem;
}

.cashier-card-heading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    min-width: 0;
}

.cashier-status-badge {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    background: rgba(16, 185, 129, 0.12);
    color: var(--success);
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}

.cash-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 0.625rem;
    background: var(--border);
}

.cash-summary-item {
    min-width: 0;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
}

.cash-summary-label {
    display: block;
    overflow: hidden;
    color: var(--text-secondary);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.cash-summary-value {
    display: block;
    margin-top: 0.25rem;
    overflow: hidden;
    color: var(--text-primary);
    font-size: 1.0625rem;
    line-height: 1.25;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.cash-summary-value.success {
    color: var(--success);
}

.cash-summary-note {
    display: block;
    margin-top: 0.2rem;
    overflow: hidden;
    color: var(--text-secondary);
    font-size: 0.6875rem;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.cash-summary-extra {
    margin: 0.75rem 0 0;
    color: var(--text-secondary);
    font-size: 0.75rem;
}

@media (max-width: 1250px) {
    .pos-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .cash-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .pos-catalog-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 520px) {
    .cash-summary-grid {
        grid-template-columns: 1fr;
    }
    .cashier-cash-card .card-header {
        align-items: flex-start;
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    .catalog-page-size {
        display: none;
    }
    .catalog-meta {
        flex-direction: column;
        gap: 0.25rem;
    }
}

/* Mode layar penuh kasir: hanya panel transaksi dan katalog */
body.pos-focus-active {
    overflow: hidden;
}

.pos-layout:fullscreen,
.pos-layout.pos-focus-mode {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    box-sizing: border-box;
    padding: 1rem;
    gap: 1rem;
    grid-template-columns: 400px minmax(0, 1fr);
    background: var(--bg-primary);
    overflow: hidden;
}

.pos-layout:fullscreen::backdrop {
    background: var(--bg-primary);
}

.pos-layout.pos-focus-mode {
    position: fixed;
    inset: 0;
    z-index: 1000;
}

.pos-layout:fullscreen > .card,
.pos-layout.pos-focus-mode > .card {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 100%;
    min-height: 0;
    margin-bottom: 0;
}

.pos-layout:fullscreen > .card > .card-header,
.pos-layout.pos-focus-mode > .card > .card-header {
    flex: 0 0 auto;
}

.pos-layout:fullscreen > .card > .card-body,
.pos-layout.pos-focus-mode > .card > .card-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

.pos-layout:fullscreen #catalogCard > .card-body,
.pos-layout.pos-focus-mode #catalogCard > .card-body {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pos-layout:fullscreen #catalogCard .pos-catalog-grid,
.pos-layout.pos-focus-mode #catalogCard .pos-catalog-grid {
    flex: 1 1 auto;
    min-height: 0;
    grid-template-rows: repeat(3, minmax(120px, 1fr));
    overflow-y: auto;
}

.pos-layout:fullscreen #catalogCard .product-catalog-card .catalog-media,
.pos-layout.pos-focus-mode #catalogCard .product-catalog-card .catalog-media,
.pos-layout:fullscreen #catalogCard .product-catalog-card .catalog-placeholder,
.pos-layout.pos-focus-mode #catalogCard .product-catalog-card .catalog-placeholder {
    flex: 1 1 auto;
    min-height: 0;
    aspect-ratio: auto;
}

@media (max-width: 1100px) {
    .pos-layout:fullscreen,
    .pos-layout.pos-focus-mode {
        grid-template-columns: 340px minmax(0, 1fr);
    }
}

@media (max-width: 860px) {
    .pos-layout:fullscreen,
    .pos-layout.pos-focus-mode {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
    }
    .pos-layout:fullscreen .catalog-page-size,
    .pos-layout.pos-focus-mode .catalog-page-size {
        display: none;
    }
}
