/**
 * AJCart / Stock Manager — global theme tokens
 *
 * Change colors HERE to update the whole app.
 *
 * CSS usage:  color: var(--theme-primary);
 * JS usage:   AppTheme.primary()  or  AppTheme.color('chart-1')
 */
:root {
    /* Brand */
    --theme-primary: #0d7a5c;
    --theme-primary-dark: #095c46;
    --theme-primary-light: #14b8a6;
    --theme-primary-soft: #e8f5f0;
    --theme-primary-rgb: 13, 122, 92;
    --theme-accent: #435ebe;
    --theme-accent-light: #57caeb;


    /* --theme-primary: #2563eb;
    --theme-primary-dark: #1d4ed8;
    --theme-primary-light: #60a5fa;
    --theme-primary-soft: #eff6ff;
    --theme-primary-rgb: 37, 99, 235;
    --theme-accent: #435ebe;
    --theme-accent-light: #57caeb; */
    

    /* Text */
    --theme-text: #25396f;
    --theme-text-secondary: #334155;
    --theme-text-muted: #64748b;
    --theme-text-light: #7c8db5;
    --theme-text-inverse: #ffffff;

    /* Surfaces */
    --theme-bg: #f2f7ff;
    --theme-surface: #ffffff;
    --theme-surface-alt: #f8fafc;
    --theme-surface-hover: #f1f5f9;
    --theme-border: #e8edf5;
    --theme-border-light: #f1f5f9;
    --theme-border-strong: #e2e8f0;

    /* Status */
    --theme-danger: #dc3545;
    --theme-danger-dark: #b91c1c;
    --theme-danger-soft: #fef2f2;
    --theme-danger-border: #fecaca;
    --theme-danger-border-hover: #fca5a5;
    --theme-success: #198754;
    --theme-warning: #ffc107;
    --theme-info: #0dcaf0;

    /* Gradients */
    --theme-gradient-primary: linear-gradient(135deg, var(--theme-primary) 0%, var(--theme-primary-light) 100%);
    --theme-gradient-avatar: linear-gradient(135deg, var(--theme-primary), var(--theme-primary-light));

    /* Shadows */
    --theme-shadow-sm: 0 1px 3px rgba(37, 57, 111, 0.04);
    --theme-shadow-md: 0 5px 20px rgba(37, 57, 111, 0.06);
    --theme-shadow-lg: 0 12px 40px rgba(37, 57, 111, 0.12);
    --theme-shadow-sidebar: 4px 0 24px rgba(15, 23, 42, 0.15);
    --theme-shadow-primary: 0 4px 12px rgba(var(--theme-primary-rgb), 0.3);
    --theme-shadow-accent: 0 4px 14px rgba(var(--theme-primary-rgb), 0.25);

    /* Layout */
    --theme-sidebar-width: 300px;
    --theme-radius-sm: 0.45rem;
    --theme-radius-md: 0.65rem;
    --theme-radius-lg: 0.7rem;
    --theme-radius-xl: 0.85rem;

    /* Charts (used by JS via AppTheme) */
    --theme-chart-1: #0d7a5c;
    --theme-chart-2: #435ebe;
    --theme-chart-3: #57caeb;
    --theme-chart-4: #5ddab4;
    --theme-chart-5: #ff7976;
    --theme-chart-label: #304568;
    --theme-chart-grid: #e2e8f0;

    /* Legacy aliases — keep old names working */
    --shell-primary: var(--theme-primary);
    --shell-primary-dark: var(--theme-primary-dark);
    --shell-sidebar-width: var(--theme-sidebar-width);

    /* Landing page aliases */
    --stock-primary: #10336b;
    --stock-primary-light: #1a4a8a;
    --stock-accent: var(--theme-primary);
    --stock-accent-hover: var(--theme-primary-dark);
    --stock-accent-soft: var(--theme-primary-soft);
    --stock-red: #a61917;
    --stock-bg: #f4f7fb;
    --stock-surface: var(--theme-surface);
    --stock-border: var(--theme-border-strong);
    --stock-text: #0f172a;
    --stock-muted: #64748b;
    --stock-shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
    --stock-shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.1);
}

/* Bootstrap overrides for console pages */
body.stock-app {
    --bs-primary: var(--theme-primary);
    --bs-primary-rgb: var(--theme-primary-rgb);
    --bs-success: var(--theme-primary);
    --bs-success-rgb: var(--theme-primary-rgb);
}

body.stock-app .btn-primary,
body.stock-app .btn-success {
    background-color: var(--theme-primary) !important;
    border-color: var(--theme-primary) !important;
    color: var(--theme-text-inverse) !important;
}

body.stock-app .btn-primary:hover,
body.stock-app .btn-primary:focus,
body.stock-app .btn-primary:active,
body.stock-app .btn-success:hover,
body.stock-app .btn-success:focus,
body.stock-app .btn-success:active {
    background-color: var(--theme-primary-dark) !important;
    border-color: var(--theme-primary-dark) !important;
    color: var(--theme-text-inverse) !important;
}

body.stock-app #quickAddBtn {
    background-color: var(--theme-primary) !important;
    border-color: var(--theme-primary) !important;
    color: var(--theme-text-inverse) !important;
    box-shadow: var(--theme-shadow-primary) !important;
}

body.stock-app #quickAddBtn:hover,
body.stock-app #quickAddBtn:focus {
    background-color: var(--theme-primary-dark) !important;
    border-color: var(--theme-primary-dark) !important;
}

body.stock-app #scanBtn {
    background-color: var(--theme-primary-dark) !important;
    border-color: var(--theme-primary-dark) !important;
    color: var(--theme-text-inverse) !important;
    box-shadow: var(--theme-shadow-primary) !important;
}

body.stock-app #scanBtn:hover,
body.stock-app #scanBtn:focus {
    background-color: var(--theme-primary) !important;
    border-color: var(--theme-primary) !important;
}

/* Cart console uses same theme tokens as stock */
body.cart-app {
    --bs-primary: var(--theme-primary);
    --bs-primary-rgb: var(--theme-primary-rgb);
    --bs-success: var(--theme-primary);
    --bs-success-rgb: var(--theme-primary-rgb);
}

body.cart-app .btn-primary,
body.cart-app .btn-success {
    background-color: var(--theme-primary) !important;
    border-color: var(--theme-primary) !important;
    color: var(--theme-text-inverse) !important;
}

body.cart-app .btn-primary:hover,
body.cart-app .btn-primary:focus,
body.cart-app .btn-primary:active,
body.cart-app .btn-success:hover,
body.cart-app .btn-success:focus,
body.cart-app .btn-success:active {
    background-color: var(--theme-primary-dark) !important;
    border-color: var(--theme-primary-dark) !important;
    color: var(--theme-text-inverse) !important;
}

/* Shared console modals */
body.cart-app .modal-content,
body.stock-app .modal-content {
    border: none;
    border-radius: var(--theme-radius-xl);
    box-shadow: var(--theme-shadow-lg);
    background: var(--theme-surface);
}

body.cart-app .modal-header,
body.cart-app .modal-header.gradient-custom,
body.stock-app .modal-header,
body.stock-app .modal-header.gradient-custom {
    background: var(--theme-gradient-primary);
    border: none;
    padding: 1rem 1.25rem;
    border-radius: var(--theme-radius-xl) var(--theme-radius-xl) 0 0;
}

body.cart-app .modal-header .modal-title,
body.stock-app .modal-header .modal-title {
    color: var(--theme-text-inverse);
    font-size: 1.05rem;
    font-weight: 600;
}

body.cart-app .modal-icon-circle,
body.stock-app .modal-icon-circle {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

body.cart-app .modal-footer,
body.stock-app .modal-footer {
    background: var(--theme-surface-alt);
    border-top: 1px solid var(--theme-border);
    border-radius: 0 0 var(--theme-radius-xl) var(--theme-radius-xl);
}

body.cart-app .btn-light-secondary,
body.stock-app .btn-light-secondary {
    background: var(--theme-surface);
    border: 1px solid var(--theme-border-strong);
    color: var(--theme-text-secondary);
}

body.cart-app .btn-light-secondary:hover,
body.stock-app .btn-light-secondary:hover {
    background: var(--theme-surface-hover);
    border-color: var(--theme-border-strong);
    color: var(--theme-text);
}

/* Profile Details modal — wide, no inner scroll */
#profileModal .modal-dialog,
#profileModal .profile-modal-dialog {
    max-width: 760px;
    width: calc(100% - 2rem);
    margin: 1rem auto;
}

#profileModal .modal-content {
    overflow: hidden;
    max-height: none;
}

#profileModal .modal-body {
    padding: 1.1rem 1.25rem 0.35rem;
    background: var(--theme-surface);
    overflow: visible;
    max-height: none;
}

#profileModal .profile-layout {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

#profileModal .profile-hero {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 1rem;
    text-align: left;
    margin-bottom: 0;
    padding: 0.85rem 1rem;
    border: 1px solid var(--theme-border);
    border-radius: var(--theme-radius-lg);
    background: var(--theme-surface-alt);
}

#profileModal .profile-hero-text {
    min-width: 0;
}

#profileModal .profile-hero-text #userName {
    margin: 0 0 0.35rem;
}

#profileModal .profile-sales-chip {
    text-align: center;
    min-width: 110px;
    padding: 0.55rem 0.85rem;
    border-radius: var(--theme-radius-md);
    background: var(--theme-primary-soft);
}

#profileModal .profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.9rem;
}

#profileModal .profile-avatar-wrap {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    padding: 0;
    background: var(--theme-gradient-avatar);
    box-shadow: var(--theme-shadow-primary);
    display: grid;
    place-items: center;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

#profileModal .profile-avatar-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    border: 3px solid var(--theme-surface);
    background: var(--theme-surface-alt);
    z-index: 1;
}

#profileModal .profile-avatar-fallback {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    z-index: 0;
    color: var(--theme-text-inverse);
    margin: 0;
    padding: 0;
}

#profileModal .profile-avatar-fallback i {
    font-size: 2rem;
    line-height: 1;
    display: block;
    width: 1em;
    height: 1em;
    margin: 0;
}

#profileModal .is-hidden,
.profile-avatar-btn .is-hidden {
    display: none !important;
}

#profileModal .profile-avatar-wrap.has-photo .profile-avatar-fallback {
    display: none !important;
}

/* Header avatar button */
.profile-avatar-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 2px solid rgba(var(--theme-primary-rgb), 0.25);
    background: var(--theme-gradient-avatar);
    color: var(--theme-text-inverse);
    display: inline-grid;
    place-items: center;
    padding: 0;
    cursor: pointer;
    overflow: hidden;
    position: relative;
}

.profile-avatar-btn .profile-avatar-icon {
    font-size: 1.35rem;
    line-height: 1;
    width: 1em;
    height: 1em;
    display: block;
}

.profile-avatar-btn .profile-avatar-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.profile-avatar-btn:hover {
    transform: scale(1.06);
    box-shadow: var(--theme-shadow-primary);
}

/* Soft backdrop — avoid solid black */
body.cart-app .modal-backdrop {
    background-color: rgba(15, 23, 42, 0.32) !important;
    opacity: 1 !important;
}

body.cart-app .modal-backdrop.show {
    opacity: 1 !important;
}

body.cart-app .modal {
    background: transparent;
}

#profileModal #userName {
    margin: 0;
    color: var(--theme-text);
    font-size: 1.15rem;
    font-weight: 700;
}

#profileModal .profile-role-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.28rem 0.75rem;
    border-radius: 999px;
    background: var(--theme-surface);
    color: var(--theme-primary-dark);
    font-size: 0.8rem;
    font-weight: 600;
}

#profileModal .profile-section {
    border: 1px solid var(--theme-border);
    border-radius: var(--theme-radius-lg);
    background: var(--theme-surface-alt);
    padding: 0.85rem 1rem;
    margin-bottom: 0;
    text-align: left;
}

#profileModal .profile-section-title {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0 0 0.55rem;
    color: var(--theme-primary-dark);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

#profileModal .profile-section-title i {
    font-size: 0.95rem;
}

#profileModal .profile-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.32rem 0;
    border-bottom: 1px solid var(--theme-border-light);
}

#profileModal .profile-meta-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

#profileModal .profile-meta-label {
    color: var(--theme-text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    flex-shrink: 0;
}

#profileModal .profile-meta-value {
    color: var(--theme-text);
    font-size: 0.86rem;
    font-weight: 600;
    text-align: right;
    word-break: break-word;
}

#profileModal .profile-sales-value {
    color: var(--theme-primary);
    font-size: 1.45rem;
    font-weight: 800;
    line-height: 1.1;
}

#profileModal .profile-sales-label {
    color: var(--theme-text-muted);
    font-size: 0.75rem;
}

#profileModal .modal-footer {
    border: none;
    padding: 0.75rem 1.25rem 1.1rem;
    justify-content: stretch;
}

#profileModal #logoutBtn {
    width: 100%;
    max-width: none;
    margin: 0;
    border: none;
    border-radius: var(--theme-radius-md);
    background: var(--theme-danger) !important;
    color: var(--theme-text-inverse) !important;
    font-weight: 600;
    padding: 0.65rem 1rem;
    box-shadow: none;
}

#profileModal #logoutBtn:hover {
    background: var(--theme-danger-dark) !important;
    transform: none;
    box-shadow: var(--theme-shadow-sm);
}

@media (max-width: 700px) {
    #profileModal .profile-hero {
        grid-template-columns: auto 1fr;
    }

    #profileModal .profile-sales-chip {
        grid-column: 1 / -1;
    }

    #profileModal .profile-grid {
        grid-template-columns: 1fr;
    }
}

/* =========================================================
   Cart POS chrome → global theme (same green as stock / mcart)
   theme.css loads last, so these win over home.css / header.css
   ========================================================= */
body.cart-app {
    --primary-color: var(--theme-surface);
    --secondary-color: var(--theme-primary-dark);
    --accent-color: var(--theme-primary);
    --success-color: var(--theme-primary);
    --light-gray: var(--theme-bg);
    --background-gray: var(--theme-bg);
    --border-color: var(--theme-border);
    --text-dark: var(--theme-text);
    --text-light: var(--theme-text-light);
    background-color: var(--theme-bg);
    color: var(--theme-text);
}

body.cart-app .nav,
body.cart-app .nav-tabs,
body.cart-app .dropdown-wrapper,
body.cart-app .category-navigation,
body.cart-app .cart-header,
body.cart-app .cart-footer {
    background: var(--theme-surface) !important;
    background-color: var(--theme-surface) !important;
    color: var(--theme-text) !important;
    border-color: var(--theme-border) !important;
}

body.cart-app .nav {
    border-bottom: 1px solid var(--theme-border) !important;
}

body.cart-app .nav-link,
body.cart-app .dropdown-item,
body.cart-app .cart-footer .text-link,
body.cart-app .device-id {
    color: var(--theme-primary) !important;
}

body.cart-app .nav-link.active,
body.cart-app .nav-tabs .nav-link.active {
    background: var(--theme-primary-soft) !important;
    color: var(--theme-primary-dark) !important;
}

body.cart-app .nav-link.active::after {
    background-color: var(--theme-primary) !important;
}

body.cart-app .dropdown-item:hover,
body.cart-app .dropdown-item:focus {
    background: var(--theme-primary-soft) !important;
    color: var(--theme-primary-dark) !important;
}

body.cart-app .previous-orders-btn,
body.cart-app .search-container .user-id-btn,
body.cart-app .user-id-btn,
body.cart-app #userOrdersModal .user-id.badge,
body.cart-app #userIdEntryModal .btn-primary,
body.cart-app #manualIdEntryConfirmModal .btn-primary,
body.cart-app .btn-generate-bill,
body.cart-app #rzp-button1 {
    background: var(--theme-primary) !important;
    background-color: var(--theme-primary) !important;
    border-color: var(--theme-primary) !important;
    color: var(--theme-text-inverse) !important;
}

body.cart-app .previous-orders-btn:hover,
body.cart-app .search-container .user-id-btn:hover,
body.cart-app .user-id-btn:hover,
body.cart-app #userIdEntryModal .btn-primary:hover,
body.cart-app #manualIdEntryConfirmModal .btn-primary:hover,
body.cart-app .btn-generate-bill:hover,
body.cart-app #rzp-button1:hover {
    background: var(--theme-primary-dark) !important;
    background-color: var(--theme-primary-dark) !important;
    border-color: var(--theme-primary-dark) !important;
    color: var(--theme-text-inverse) !important;
}

body.cart-app #userIdEntryModal .form-control:focus,
body.cart-app #userIdEntryModal .input-group:focus-within .input-group-text,
body.cart-app #manualIdEntryConfirmModal .form-control:focus,
body.cart-app #manualIdEntryConfirmModal .input-group:focus-within .input-group-text,
body.cart-app #creditPaymentModal .form-select:focus,
body.cart-app #cashPaymentModal .form-control:focus {
    border-color: var(--theme-primary) !important;
    box-shadow: 0 0 0 0.2rem rgba(var(--theme-primary-rgb), 0.2) !important;
}

body.cart-app .cart-header,
body.cart-app .nav-tabs,
body.cart-app .dropdown-wrapper {
    background: var(--theme-surface) !important;
    background-color: var(--theme-surface) !important;
}

body.cart-app .btn-sm-primary,
body.cart-app .btn-light-primary {
    background-color: var(--theme-primary-soft) !important;
    color: var(--theme-primary-dark) !important;
    border-color: transparent !important;
}

body.cart-app .category-scroll-btn,
body.cart-app .scroll-btn {
    background: var(--theme-primary) !important;
    color: var(--theme-text-inverse) !important;
    border-color: var(--theme-primary) !important;
}

body.cart-app .category-box:hover,
body.cart-app .item-card:hover {
    box-shadow: var(--theme-shadow-md);
}

body.cart-app .btn-outline-primary {
    color: var(--theme-primary) !important;
    border-color: var(--theme-primary) !important;
}

body.cart-app .btn-outline-primary:hover {
    background: var(--theme-primary) !important;
    color: var(--theme-text-inverse) !important;
}

body.cart-app .text-primary {
    color: var(--theme-primary) !important;
}

body.cart-app .bg-primary {
    background-color: var(--theme-primary) !important;
}

body.cart-app .badge.bg-primary {
    background-color: var(--theme-primary) !important;
}

body.cart-app .scrollbar,
body.cart-app * {
    scrollbar-color: var(--theme-primary) var(--theme-bg);
}
