/* ============================================================================
   Aabharanam POS - Main Stylesheet
   Pure CSS, no framework. Theme: Aabharanam Fashion Jewellery
   Palette derived from the shop's signage: warm ivory/gold (light) and
   black/gold (dark) - the sidebar always stays black+gold as the brand
   anchor; the content area toggles between the two via the Light/Dark switch.
   ============================================================================ */

:root {
    /* Brand palette */
    --gold: #C9A227;
    --gold-bright: #E8C874;
    --gold-dark: #9C7A17;
    --maroon: #7A1128;
    --rose: #D88AA0;

    /* Light theme (default) - ivory & gold, echoes the cream signboard */
    --bg-soft: #FDF6E8;
    --bg-panel: #FBF1DD;
    --text-main: #2B2118;
    --text-muted: #8A7A5E;
    --border-color: #E9DBB8;
    --white: #FFFFFF;
    --danger: #C13333;
    --warning: #B4791A;
    --success: #2F7D4F;
    --info: #2E6E8E;

    /* Sidebar - always black + gold regardless of the light/dark toggle */
    --sidebar-bg: #0A0806;
    --sidebar-bg-alt: #17130D;
    --sidebar-text: #E8DCC0;
    --sidebar-text-muted: #9C8F76;

    --radius: 14px;
    --radius-sm: 8px;
    --shadow-soft: 0 4px 18px rgba(43, 33, 24, 0.08);
    --shadow-med: 0 8px 30px rgba(43, 33, 24, 0.14);
    --grad-primary: linear-gradient(135deg, #C9A227 0%, #E8C874 100%);
    --grad-gold-text: linear-gradient(135deg, #9C7A17 0%, #C9A227 100%);
    --font-display: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ---------------------------------------------------------------------- */
/* Dark theme override - toggled via [data-theme="dark"] on <html>         */
/* Echoes the black + gold signboard variant                               */
/* ---------------------------------------------------------------------- */
[data-theme="dark"] {
    --bg-soft: #121012;
    --bg-panel: #1B1712;
    --text-main: #F3EAD8;
    --text-muted: #B4A488;
    --border-color: #3A3226;
    --white: #211D17;
    --danger: #E36767;
    --warning: #E0AC4F;
    --success: #5FBE85;
    --info: #6FB8DD;
    --shadow-soft: 0 4px 18px rgba(0, 0, 0, 0.35);
    --shadow-med: 0 8px 30px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-display);
    background: var(--bg-soft);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
    transition: background-color .2s ease, color .2s ease;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; margin: 0; padding: 0; }
button { font-family: inherit; cursor: pointer; }

/* ---------------------------------------------------------------------- */
/* App Shell Layout                                                        */
/* ---------------------------------------------------------------------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-alt) 100%);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    transition: margin-left .25s ease;
    z-index: 40;
    border-right: 1px solid rgba(201, 162, 39, 0.15);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 20px;
    border-bottom: 1px solid rgba(201, 162, 39, 0.18);
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--grad-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: #221A0E;
    font-size: 16px;
    box-shadow: 0 4px 14px rgba(201, 162, 39, 0.45);
    overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }

.brand-text strong { display: block; font-size: 16px; letter-spacing: .3px; color: var(--gold-bright); }
.brand-text span { font-size: 11px; color: var(--sidebar-text-muted); text-transform: uppercase; letter-spacing: 1px; }

.sidebar-nav { padding: 14px 12px 30px; flex: 1; }

.nav-section {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--sidebar-text-muted);
    margin: 18px 12px 8px;
    font-weight: 700;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: 14px;
    margin-bottom: 2px;
    transition: background .15s ease, color .15s ease, transform .1s ease;
}

.nav-icon { width: 18px; text-align: center; font-size: 14px; opacity: .9; }

.nav-item:hover {
    background: rgba(201, 162, 39, 0.12);
    color: var(--gold-bright);
}

.nav-item.active {
    background: var(--grad-primary);
    color: #221A0E;
    font-weight: 700;
    box-shadow: 0 4px 14px rgba(201, 162, 39, 0.4);
}

.nav-logout { color: #E89999; margin-top: 10px; }
.nav-logout:hover { background: rgba(193,51,51,0.15); color: #E89999; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------------------------------------------------------------------- */
/* Topbar                                                                  */
/* ---------------------------------------------------------------------- */
.topbar {
    height: 68px;
    background: var(--white);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 30;
}

.topbar-title { font-size: 19px; font-weight: 700; margin: 0; flex: 1; }

.btn-icon {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
    color: var(--text-main);
}

.sidebar-toggle { display: none; }

.topbar-right { display: flex; align-items: center; gap: 18px; }

.badge-clock {
    font-size: 13px;
    color: var(--text-muted);
    background: var(--bg-panel);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

/* Theme toggle switch (Light / Dark) */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 4px;
}
.theme-toggle button {
    background: none;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--text-muted);
    transition: background .15s ease, color .15s ease;
}
.theme-toggle button.active {
    background: var(--grad-primary);
    color: #221A0E;
    box-shadow: 0 2px 8px rgba(201, 162, 39, 0.4);
}

.user-menu { display: flex; align-items: center; gap: 10px; }

.user-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--grad-primary);
    color: #221A0E;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
}

.user-info { display: flex; flex-direction: column; line-height: 1.3; }
.user-info strong { font-size: 13.5px; }

.role-pill {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--gold-dark);
    font-weight: 700;
}
[data-theme="dark"] .role-pill { color: var(--gold-bright); }

/* ---------------------------------------------------------------------- */
/* Content                                                                 */
/* ---------------------------------------------------------------------- */
.app-content { padding: 26px; flex: 1; }

.app-footer {
    text-align: center;
    padding: 16px;
    font-size: 12.5px;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    background: var(--white);
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h2 { margin: 0; font-size: 20px; }
.page-header p { margin: 4px 0 0; color: var(--text-muted); font-size: 13.5px; }

/* ---------------------------------------------------------------------- */
/* Cards                                                                   */
/* ---------------------------------------------------------------------- */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    padding: 20px;
    border: 1px solid var(--border-color);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-header h3 { margin: 0; font-size: 15.5px; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--grad-primary);
}

.stat-card .stat-label { font-size: 12.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.stat-card .stat-value { font-size: 26px; font-weight: 800; margin-top: 6px; color: var(--text-main); }
.stat-card .stat-icon {
    position: absolute; right: 16px; top: 16px;
    width: 40px; height: 40px;
    border-radius: 10px;
    background: var(--bg-soft);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    color: var(--gold-dark);
}

.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

@media (max-width: 900px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------------- */
/* Buttons                                                                 */
/* ---------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 13.5px;
    font-weight: 600;
    transition: transform .1s ease, box-shadow .15s ease, opacity .15s ease;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
    background: var(--grad-primary);
    color: #221A0E;
    box-shadow: 0 6px 16px rgba(201, 162, 39, 0.4);
}
.btn-primary:hover { opacity: .9; }

.btn-outline {
    background: var(--white);
    border-color: var(--border-color);
    color: var(--text-main);
}
.btn-outline:hover { border-color: var(--gold); color: var(--gold-dark); }
[data-theme="dark"] .btn-outline:hover { color: var(--gold-bright); }

.btn-danger { background: var(--danger); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; }
.btn-lg { padding: 14px 20px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------------------------------------------------------------------- */
/* Forms                                                                   */
/* ---------------------------------------------------------------------- */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }

label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-main);
}

input[type=text], input[type=password], input[type=email], input[type=number],
input[type=date], input[type=tel], input[type=file], select, textarea {
    width: 100%;
    padding: 11px 13px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--white);
    color: var(--text-main);
    transition: border-color .15s ease, box-shadow .15s ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.18);
}

.input-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.input-error { font-size: 12px; color: var(--danger); margin-top: 4px; }
.field-invalid { border-color: var(--danger) !important; }

/* ---------------------------------------------------------------------- */
/* Tables                                                                  */
/* ---------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border-color); }

table { width: 100%; border-collapse: collapse; background: var(--white); font-size: 13.5px; }

thead th {
    background: var(--bg-panel);
    text-align: left;
    padding: 12px 14px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-panel); }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .3px;
}
.badge-success { background: #DCF3E3; color: #1E6B41; }
.badge-warning { background: #F8E8C8; color: #8A5A0C; }
.badge-danger { background: #F6DADA; color: #9C2323; }
.badge-info { background: #DCEAF2; color: #205A78; }
.badge-muted { background: #EDE4CE; color: #8A7A5E; }

[data-theme="dark"] .badge-success { background: rgba(95, 190, 133, 0.18); color: #8FE0AC; }
[data-theme="dark"] .badge-warning { background: rgba(224, 172, 79, 0.18); color: #F0C583; }
[data-theme="dark"] .badge-danger { background: rgba(227, 103, 103, 0.18); color: #F0A0A0; }
[data-theme="dark"] .badge-info { background: rgba(111, 184, 221, 0.18); color: #A7D8EF; }
[data-theme="dark"] .badge-muted { background: rgba(180, 164, 136, 0.15); color: #C9BC9F; }

.pagination { display: flex; gap: 6px; margin-top: 16px; justify-content: flex-end; }
.page-link {
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    font-size: 13px;
    background: var(--white);
    color: var(--text-main);
}
.page-link.active { background: var(--grad-primary); color: #221A0E; border-color: transparent; font-weight: 700; }

/* ---------------------------------------------------------------------- */
/* Alerts & Toasts                                                         */
/* ---------------------------------------------------------------------- */
.alert {
    padding: 13px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 18px;
    font-size: 14px;
    border-left: 4px solid;
}
.alert-success { background: var(--bg-panel); border-color: var(--success); color: var(--success); }
.alert-error { background: var(--bg-panel); border-color: var(--danger); color: var(--danger); }

.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    min-width: 260px;
    max-width: 360px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    background: #221A0E;
    color: #F3EAD8;
    box-shadow: var(--shadow-med);
    font-size: 13.5px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toast-in .25s ease;
}
.toast.toast-success { border-left: 4px solid var(--success); }
.toast.toast-error { border-left: 4px solid var(--danger); }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---------------------------------------------------------------------- */
/* Login Page                                                              */
/* ---------------------------------------------------------------------- */
.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top left, #F3E4B8, #FDF6E8 45%),
                radial-gradient(circle at bottom right, #EAD9A8, transparent 55%);
    padding: 20px;
    position: relative;
}
[data-theme="dark"] .login-shell {
    background: radial-gradient(circle at top left, #201A10, #121012 45%),
                radial-gradient(circle at bottom right, #2A2013, transparent 55%);
}
.login-theme-toggle { position: absolute; top: 20px; right: 20px; }
.login-card {
    background: var(--white);
    width: 100%;
    max-width: 400px;
    border-radius: 20px;
    box-shadow: var(--shadow-med);
    padding: 40px 36px;
    border: 1px solid var(--border-color);
}
.login-brand { text-align: center; margin-bottom: 26px; }
.login-brand .brand-mark { margin: 0 auto 14px; width: 56px; height: 56px; border-radius: 16px; font-size: 20px; }
.login-brand h1 {
    font-size: 22px; margin: 0 0 4px;
    background: var(--grad-gold-text);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}
[data-theme="dark"] .login-brand h1 {
    background: linear-gradient(135deg, #C9A227 0%, #E8C874 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.login-brand p { color: var(--text-muted); font-size: 13px; margin: 0; }
.login-demo {
    margin-top: 20px;
    background: var(--bg-panel);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.6;
}

/* ---------------------------------------------------------------------- */
/* POS / Billing Screen                                                    */
/* ---------------------------------------------------------------------- */
.pos-shell {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 20px;
    align-items: start;
}
@media (max-width: 1100px) { .pos-shell { grid-template-columns: 1fr; } }

.pos-search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}
.pos-search-bar input { font-size: 15px; padding: 13px 16px; }

.pos-results {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    background: var(--white);
    display: none;
}
.pos-result-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13.5px;
}
.pos-result-item:hover { background: var(--bg-soft); cursor: pointer; }
.pos-result-item:last-child { border-bottom: none; }
.pos-result-item .stock-low { color: var(--danger); font-weight: 700; }

.cart-table td, .cart-table th { padding: 10px; }
.cart-qty-input { width: 60px; padding: 6px; text-align: center; }
.cart-rate-input { width: 80px; padding: 6px; text-align: center; }
.cart-disc-input { width: 70px; padding: 6px; text-align: center; }

.bill-summary-panel {
    position: sticky;
    top: 84px;
}
.bill-summary-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 14px;
    border-bottom: 1px dashed var(--border-color);
}
.bill-summary-row.total {
    font-size: 20px;
    font-weight: 800;
    border-bottom: none;
    color: var(--gold-dark);
    padding-top: 14px;
}
[data-theme="dark"] .bill-summary-row.total { color: var(--gold-bright); }

.payment-modes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 14px 0; }
.payment-mode-btn {
    padding: 12px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border-color);
    text-align: center;
    font-weight: 600;
    font-size: 13px;
    background: var(--white);
    color: var(--text-main);
}
.payment-mode-btn.selected { background: var(--grad-primary); color: #221A0E; border-color: transparent; }

.customer-box { display: flex; gap: 8px; margin-bottom: 14px; }

.shortcut-hint {
    font-size: 11.5px;
    color: var(--text-muted);
    background: var(--bg-panel);
    padding: 2px 8px;
    border-radius: 6px;
    margin-left: 6px;
}

.kbd { background: var(--sidebar-bg-alt); color: var(--gold-bright); padding: 1px 6px; border-radius: 4px; font-size: 11px; }

/* ---------------------------------------------------------------------- */
/* Modal                                                                   */
/* ---------------------------------------------------------------------- */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(20, 15, 8, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-overlay.open { display: flex; }
.modal-box {
    background: var(--white);
    border-radius: var(--radius);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    box-shadow: var(--shadow-med);
    color: var(--text-main);
}
.modal-box.modal-lg { max-width: 720px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-close { background: none; border: none; font-size: 20px; color: var(--text-muted); }

/* ---------------------------------------------------------------------- */
/* Camera Barcode Scanner                                                  */
/* ---------------------------------------------------------------------- */
.scanner-modal-box { max-width: 420px; text-align: center; }
.scanner-video-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #0A0806;
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.scanner-video-wrap video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.scanner-frame {
    position: absolute;
    top: 20%; left: 10%; right: 10%; bottom: 20%;
    border: 3px solid var(--gold);
    border-radius: 12px;
    box-shadow: 0 0 0 2000px rgba(10, 8, 6, 0.4);
    pointer-events: none;
}
.scanner-hint {
    margin: 12px 0 0;
    font-size: 13.5px;
    color: var(--text-muted);
}
.scan-btn-row { display: flex; gap: 10px; }
.scan-btn-row > input { flex: 1; }
.btn-camera {
    display: flex; align-items: center; justify-content: center;
    min-width: 46px;
    padding: 10px 14px;
}
.btn-camera:disabled { opacity: .4; cursor: not-allowed; }

/* ---------------------------------------------------------------------- */
/* Login/utility                                                           */
/* ---------------------------------------------------------------------- */
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.mt-0{margin-top:0} .mb-0{margin-bottom:0}
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }

.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
    align-items: end;
}
.filters-bar .form-group { margin-bottom: 0; min-width: 160px; }

.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 10px; }

/* Responsive sidebar for tablet/mobile */
@media (max-width: 860px) {
    .sidebar { position: fixed; margin-left: -260px; }
    .sidebar.open { margin-left: 0; }
    .sidebar-toggle { display: flex; }
    .app-content { padding: 16px; }
}

@media print {
    .sidebar, .topbar, .app-footer, .no-print { display: none !important; }
    .app-content { padding: 0 !important; }
}
