/**
 * Shira Fresh Grocery Mart - Professional Custom Stylesheet
 * Shirasmane Software Solutions Pvt. Ltd.
 */

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --primary-border: #bfdbfe;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active: #2563eb;
    --sidebar-text: #94a3b8;
    --body-bg: #f8fafc;
    --card-border: #e2e8f0;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --theme-name: "default";
}

/* Green Theme - Fresh Grocery */
body[data-theme="green"] {
    --primary-color: #059669;
    --primary-hover: #047857;
    --primary-light: #ecfdf5;
    --primary-border: #a7f3d0;
    --sidebar-bg: #064e3b;
    --sidebar-hover: #065f46;
    --sidebar-active: #10b981;
    --sidebar-text: #a7f3d0;
    --body-bg: #f0fdf4;
    --card-border: #d1fae5;
    --theme-name: "green";
}

/* Blue Theme - Corporate Sapphire */
body[data-theme="blue"] {
    --primary-color: #0284c7;
    --primary-hover: #0369a1;
    --primary-light: #f0f9ff;
    --primary-border: #bae6fd;
    --sidebar-bg: #0c4a6e;
    --sidebar-hover: #075985;
    --sidebar-active: #0284c7;
    --sidebar-text: #bae6fd;
    --body-bg: #f0f9ff;
    --card-border: #e0f2fe;
    --theme-name: "blue";
}

/* Orange Theme - Warm Amber */
body[data-theme="orange"] {
    --primary-color: #ea580c;
    --primary-hover: #c2410c;
    --primary-light: #fff7ed;
    --primary-border: #fed7aa;
    --sidebar-bg: #431407;
    --sidebar-hover: #7c2d12;
    --sidebar-active: #ea580c;
    --sidebar-text: #fed7aa;
    --body-bg: #fffaf5;
    --card-border: #ffedd5;
    --theme-name: "orange";
}

/* Requirement 15: Reduced font size for professional, compact look & feel */
body {
    font-size: 13px !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text-main);
    background-color: var(--body-bg);
    line-height: 1.45;
    overflow-x: hidden;
}

h1, .h1 { font-size: 1.55rem; }
h2, .h2 { font-size: 1.35rem; }
h3, .h3 { font-size: 1.20rem; }
h4, .h4 { font-size: 1.05rem; }
h5, .h5 { font-size: 0.92rem; }
h6, .h6 { font-size: 0.82rem; }

.small, small { font-size: 0.78rem; }
.badge { font-size: 0.72rem; font-weight: 600; padding: 0.35em 0.65em; }

/* Custom Primary Overrides */
.btn-primary {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}
.btn-primary:hover, .btn-primary:focus {
    background-color: var(--primary-hover) !important;
    border-color: var(--primary-hover) !important;
}
.btn-outline-primary {
    color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}
.btn-outline-primary:hover {
    background-color: var(--primary-color) !important;
    color: #fff !important;
}
.text-primary {
    color: var(--primary-color) !important;
}
.bg-primary-subtle {
    background-color: var(--primary-light) !important;
    color: var(--primary-color) !important;
}

/* Ensure single dropdown arrow on select elements across all platforms */
select, select.form-select, select.form-control {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}
select::-webkit-list-button,
select::-webkit-calendar-picker-indicator {
    display: none !important;
    opacity: 0 !important;
}
select.form-select-sm {
    height: auto !important;
    min-height: 32px !important;
    padding-top: 4px !important;
    padding-bottom: 4px !important;
    line-height: 1.35 !important;
}
select.form-select {
    height: auto !important;
    min-height: 36px !important;
    line-height: 1.35 !important;
}

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

/* Sidebar Styles */
.app-sidebar {
    width: 250px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    flex-shrink: 0;
    transition: all 0.25s ease-in-out;
    display: flex;
    flex-direction: column;
    z-index: 1030;
}

.sidebar-brand {
    padding: 16px 20px;
    font-size: 1rem;
    font-weight: 700;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-nav {
    flex-grow: 1;
    padding: 12px 10px;
    overflow-y: auto;
}

.sidebar-heading {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: rgba(255, 255, 255, 0.4);
    padding: 10px 12px 4px;
    font-weight: 700;
}

.nav-link-custom {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.82rem;
    transition: all 0.15s ease;
    margin-bottom: 2px;
}

.nav-link-custom:hover {
    color: #ffffff;
    background-color: var(--sidebar-hover);
}

.nav-link-custom.active {
    color: #ffffff;
    background-color: var(--sidebar-active);
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.nav-link-custom i {
    font-size: 1rem;
    width: 20px;
    text-align: center;
}

/* Main Content Area */
.app-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background-color: var(--body-bg);
}

/* Top Navbar */
.app-header {
    background: #ffffff;
    border-bottom: 1px solid var(--card-border);
    padding: 10px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.content-container {
    padding: 20px 24px;
    flex-grow: 1;
}

/* Cards & Tables */
.card-custom {
    background: #ffffff;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    margin-bottom: 20px;
}

.card-custom .card-header {
    background-color: #ffffff;
    border-bottom: 1px solid var(--card-border);
    padding: 12px 18px;
    font-weight: 600;
    font-size: 0.88rem;
}

.card-custom .card-body {
    padding: 18px;
}

.table-custom {
    margin-bottom: 0;
    font-size: 0.82rem;
}

.table-custom thead th {
    background-color: #f8fafc;
    color: #475569;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--card-border);
    padding: 10px 12px;
}

.table-custom tbody td {
    padding: 10px 12px;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
}

/* Financial Ledger Pillar Metric Cards */
.pillar-card {
    border-radius: 8px;
    padding: 16px 18px;
    border: 1px solid var(--card-border);
    background: #ffffff;
    position: relative;
    overflow: hidden;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.pillar-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.05);
}

.pillar-card .pillar-icon {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 10px;
}

.pillar-card .pillar-value {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.pillar-card .pillar-label {
    font-size: 0.76rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

/* POS Terminal Layout */
.pos-container {
    display: flex;
    gap: 16px;
    height: calc(100vh - 120px);
    min-height: 480px;
}

.pos-catalog {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100%;
    overflow: hidden;
}

.pos-cart {
    width: 380px;
    background: #ffffff;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex-shrink: 0;
    height: 100%;
    overflow: hidden;
}

.pos-cart-header {
    flex-shrink: 0;
    padding: 10px 14px;
    background: #f8fafc;
    border-bottom: 1px solid var(--card-border);
}

.pos-cart-items {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 8px 12px;
    min-height: 80px;
}

.pos-cart-footer {
    flex-shrink: 0;
    margin-top: auto;
    padding: 10px 14px;
    background: #f8fafc;
    border-top: 2px solid var(--card-border);
    box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.03);
}

#completeSaleBtn {
    font-weight: 700;
    letter-spacing: 0.3px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.12);
}

.pos-item-card {
    background: #ffffff;
    border: 1px solid var(--card-border);
    border-radius: 6px;
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.pos-item-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 10px rgba(0,0,0,0.06);
    transform: translateY(-1px);
}

/* Theme Selector Buttons */
.theme-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: inline-block;
    cursor: pointer;
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 1px #cbd5e1;
    transition: transform 0.15s;
}
.theme-dot:hover {
    transform: scale(1.2);
}
.theme-dot.default { background-color: #2563eb; }
.theme-dot.green { background-color: #059669; }
.theme-dot.blue { background-color: #0284c7; }
.theme-dot.orange { background-color: #ea580c; }

/* Footer */
.app-footer {
    background: #ffffff;
    border-top: 1px solid var(--card-border);
    padding: 12px 24px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* Responsive & Mobile Offcanvas Toggle (Requirement 10) */
@media (max-width: 991.98px) {
    .app-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: -260px;
        box-shadow: 2px 0 10px rgba(0,0,0,0.2);
    }
    .app-sidebar.show {
        left: 0;
    }
    .sidebar-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1025;
        display: none;
    }
    .sidebar-backdrop.show {
        display: block;
    }
    .pos-container {
        flex-direction: column;
        height: auto;
    }
    .pos-cart {
        width: 100%;
    }
}

/* Comprehensive Mobile Screen Optimizations (<768px) */
@media (max-width: 767.98px) {
    body {
        font-size: 13px !important;
    }

    .app-header {
        padding: 8px 12px;
        gap: 8px;
    }

    .content-container {
        padding: 10px 8px;
    }

    .card-custom {
        margin-bottom: 14px;
        border-radius: 8px;
    }

    .card-custom .card-header {
        padding: 10px 12px;
        font-size: 0.85rem;
    }

    .card-custom .card-body {
        padding: 12px 10px;
    }

    /* All tabular data tables keep readable minimum width for smooth horizontal scroll */
    .table-responsive > .table:not(.table-mobile-card):not(.table-no-min-width):not(#itemsTable) {
        min-width: 600px;
    }

    .table-responsive {
        -webkit-overflow-scrolling: touch;
        margin-bottom: 8px;
    }

    /* Touch-friendly input fields and buttons */
    .form-control, .form-select, .btn:not(.btn-xs) {
        min-height: 36px;
        touch-action: manipulation;
    }
    .form-control-sm, .form-select-sm, .btn-sm {
        min-height: 32px;
    }
    .btn-xs {
        min-height: 24px !important;
        font-size: 0.70rem !important;
        padding: 2px 6px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    #categoryPills .category-btn {
        white-space: nowrap !important;
    }

    /* Requirement 12: Purchase Create items Mobile Card Layout */
    .purchase-item-card {
        border: 1px solid #cbd5e1 !important;
        border-radius: 8px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.04);
        margin-bottom: 10px;
    }
    .purchase-item-card:hover {
        border-color: var(--primary-border) !important;
    }
    .purchase-item-card .form-label {
        font-size: 0.75rem;
        margin-bottom: 2px;
    }

    /* POS Terminal Mobile Enhancements */
    .pos-catalog #productsGrid {
        max-height: 380px !important;
    }
    .pos-item-card {
        padding: 8px 10px;
    }

    /* Summary cards on mobile */
    .pillar-card {
        padding: 12px 14px;
        margin-bottom: 8px;
    }
    .pillar-card .pillar-value {
        font-size: 1.25rem;
    }
}

/* Print styles for thermal & A4 */
@media print {
    body {
        background: #ffffff !important;
        font-size: 12px !important;
    }
    .no-print, .app-sidebar, .app-header, .app-footer, .sidebar-backdrop {
        display: none !important;
    }
    .app-main {
        margin: 0 !important;
        padding: 0 !important;
    }
    .content-container {
        padding: 0 !important;
    }
}
