/* Custom Retail Store Billing POS Stylesheet */

:root {
    /* Brand palette (dark theme default) */
    --bg-color: #0f172a;
    --bg-color-rgb: 15, 23, 42;
    --card-bg: #1a2436;
    --surface-alt: rgba(2, 6, 23, 0.4);
    --surface-hover: rgba(148, 163, 184, 0.08);
    --input-bg: #0f172a;
    --text-color: #f1f5f9;
    --text-muted: #97a3b8;
    --border-color: #2f3c53;
    --border-color-soft: rgba(148, 163, 184, 0.12);

    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --primary-rgb: 99, 102, 241;
    --accent-color: #10b981;
    --accent-rgb: 16, 185, 129;
    --danger-color: #ef4444;
    --danger-rgb: 239, 68, 68;
    --warning-color: #f59e0b;
    --warning-rgb: 245, 158, 11;
    --info-color: #38bdf8;
    --info-rgb: 56, 189, 248;

    /* Elevation & shape scale */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.15);
    --shadow-md: 0 10px 20px -8px rgba(0, 0, 0, 0.35), 0 4px 8px -4px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 24px 32px -12px rgba(0, 0, 0, 0.45), 0 8px 12px -6px rgba(0, 0, 0, 0.3);

    --sidebar-width: 250px;
    --navbar-height: 70px;
}

[data-theme="light"] {
    --bg-color: #f4f6fb;
    --bg-color-rgb: 244, 246, 251;
    --card-bg: #ffffff;
    --surface-alt: rgba(100, 116, 139, 0.06);
    --surface-hover: rgba(79, 70, 229, 0.05);
    --input-bg: #f8fafc;
    --text-color: #101828;
    --text-muted: #5c6b83;
    --border-color: #e2e6f0;
    --border-color-soft: rgba(15, 23, 42, 0.08);

    --primary-color: #4f46e5;
    --primary-hover: #3d34c9;
    --primary-rgb: 79, 70, 229;
    --accent-color: #059669;
    --accent-rgb: 5, 150, 105;
    --danger-color: #dc2626;
    --danger-rgb: 220, 38, 38;
    --warning-color: #d97706;
    --warning-rgb: 217, 119, 6;
    --info-color: #0284c7;
    --info-rgb: 2, 132, 199;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 10px 20px -8px rgba(15, 23, 42, 0.12), 0 4px 8px -4px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 24px 32px -12px rgba(15, 23, 42, 0.16), 0 8px 12px -6px rgba(15, 23, 42, 0.1);
}

/* --- Bring Bootstrap's own brand colors in line with the app palette so
   btn-primary / bg-primary / badges / alerts all read as one system --- */
:root, [data-theme="light"] {
    --bs-primary: var(--primary-color);
    --bs-primary-rgb: var(--primary-rgb);
    --bs-success: var(--accent-color);
    --bs-success-rgb: var(--accent-rgb);
    --bs-danger: var(--danger-color);
    --bs-danger-rgb: var(--danger-rgb);
    --bs-warning: var(--warning-color);
    --bs-warning-rgb: var(--warning-rgb);
    --bs-info: var(--info-color);
    --bs-info-rgb: var(--info-rgb);
    --bs-link-color: var(--primary-color);
    --bs-link-color-rgb: var(--primary-rgb);
    --bs-link-hover-color: var(--primary-hover);
    --bs-body-color: var(--text-color);
    --bs-body-bg: var(--bg-color);
    --bs-border-color: var(--border-color);
}

.btn-primary {
    --bs-btn-bg: var(--primary-color);
    --bs-btn-border-color: var(--primary-color);
    --bs-btn-hover-bg: var(--primary-hover);
    --bs-btn-hover-border-color: var(--primary-hover);
    --bs-btn-active-bg: var(--primary-hover);
    --bs-btn-active-border-color: var(--primary-hover);
    --bs-btn-focus-shadow-rgb: var(--primary-rgb);
    --bs-btn-disabled-bg: var(--primary-color);
    --bs-btn-disabled-border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.btn-outline-primary {
    --bs-btn-color: var(--primary-color);
    --bs-btn-border-color: var(--primary-color);
    --bs-btn-hover-bg: var(--primary-color);
    --bs-btn-hover-border-color: var(--primary-color);
    --bs-btn-active-bg: var(--primary-color);
    --bs-btn-active-border-color: var(--primary-color);
    --bs-btn-focus-shadow-rgb: var(--primary-rgb);
}

.btn {
    font-weight: 500;
    letter-spacing: 0.01em;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    transition: background-color 0.3s, color 0.3s;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    letter-spacing: -0.01em;
}

/* Comfortable, brand-colored focus ring for keyboard navigation */
a:focus-visible,
button:focus-visible,
.btn:focus-visible,
input:focus-visible,
select:focus-visible,
.form-control:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Slim, theme-aware scrollbars */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

*::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 8px;
}

*::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-muted);
}

/* --- THEME CONTRAST & ACCESSIBILITY OVERRIDES --- */

/* Override hardcoded Bootstrap dark/light text utilities */
.text-light {
    color: var(--text-color) !important;
}

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

.bg-dark {
    background-color: var(--card-bg) !important;
}

.border-secondary, .border-secondary-subtle {
    border-color: var(--border-color) !important;
}

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

.modal-header, .modal-footer {
    border-color: var(--border-color) !important;
}

/* Forms input adaptation */
.form-control, .form-select, .input-group-text {
    background-color: var(--input-bg) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-color) !important;
    border-radius: var(--radius-sm);
}

.form-control:focus, .form-select:focus {
    background-color: var(--input-bg) !important;
    border-color: var(--primary-color) !important;
    color: var(--text-color) !important;
    box-shadow: 0 0 0 0.25rem rgba(var(--primary-rgb), 0.2) !important;
}

.form-control::placeholder {
    color: var(--text-muted) !important;
    opacity: 0.7;
}

.form-label {
    font-weight: 500;
}

/* Cards theme correction */
.card {
    background-color: var(--card-bg) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-color) !important;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

/* Tables theme correction */
.table {
    color: var(--text-color) !important;
}

.table th, .table td {
    border-color: var(--border-color) !important;
}

/* --- LAYOUT STYLING --- */

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--card-bg);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    transition: all 0.3s;
}

.sidebar-logo {
    height: var(--navbar-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: -0.02em;
}

.sidebar-menu {
    padding: 1.5rem 0;
    list-style: none;
    margin: 0;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.2s;
    font-weight: 500;
    border-left: 4px solid transparent;
}

.sidebar-menu li a:hover {
    color: var(--text-color);
    background-color: var(--surface-hover);
}

.sidebar-menu li.active a {
    color: var(--primary-color);
    background-color: rgba(var(--primary-rgb), 0.1);
    border-left: 4px solid var(--primary-color);
    font-weight: 600;
}

.sidebar-menu li a i {
    margin-right: 0.75rem;
    font-size: 1.1rem;
    width: 1.25rem;
    text-align: center;
}

/* Main Layout content wrapper */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.top-navbar {
    height: var(--navbar-height);
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 999;
}

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

/* Auto-detected location badge in top navbar */
.geo-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    background-color: var(--surface-alt);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

/* User avatar chip in top navbar */
.avatar-chip {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.02em;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

#theme-toggle {
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: background-color 0.2s, color 0.2s;
}

#theme-toggle:hover {
    background-color: var(--surface-hover);
    color: var(--primary-color);
}

/* Premium Dashboard Metrics Cards */
.metric-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.metric-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.metric-info h3 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0;
}

.metric-info span {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* POS Terminal Grid Custom Design */
.pos-container {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 1.5rem;
    height: calc(100vh - var(--navbar-height) - 4rem);
}

.pos-catalog {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.pos-cart-panel {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.pos-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
    overflow-y: auto;
    padding-right: 0.5rem;
    flex: 1;
}

.product-item-card {
    background-color: var(--surface-alt);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.product-item-card:hover {
    border-color: var(--primary-color);
    background-color: rgba(var(--primary-rgb), 0.06);
    transform: scale(1.02);
    box-shadow: var(--shadow-sm);
}

/* Custom Table Dark Look */
.custom-table {
    color: var(--text-color);
}

.custom-table thead {
    background-color: var(--surface-alt);
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
}

.custom-table tbody tr {
    border-bottom: 1px solid var(--border-color-soft);
    transition: background-color 0.15s;
}

.custom-table tbody tr:hover {
    background-color: var(--surface-hover);
}

/* Auth Pages Style overrides */
.auth-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 15% 20%, rgba(var(--primary-rgb), 0.12), transparent 40%),
        radial-gradient(circle at 85% 80%, rgba(var(--accent-rgb), 0.10), transparent 40%),
        var(--bg-color);
    padding: 1.5rem;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
}

/* POS checkout payment breakdown list */
.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px dashed var(--border-color);
}
.summary-row.total {
    font-size: 1.25rem;
    font-weight: 700;
    border-bottom: none;
    color: var(--accent-color);
}
