/* GLOBAL RESET */
*,
*::before,
*::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg-color: #0f172a;
    --text-color: #e2e8f0;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --card-bg: #1e293b;
    --border-color: #334155;
    --input-bg: #0f172a;
    --danger: #ef4444;
    --success: #22c55e;
}

html,
body {
    overflow-x: hidden;
    width: 100%;
}

/* Light Theme Overrides - "Relaxing Blue" */
[data-theme="light"] {
    --bg-color: #f0f9ff;
    /* Sky 50 - Very soft airy blue */
    --text-color: #334155;
    /* Slate 700 - Softer than black */
    --card-bg: #ffffff;
    --border-color: #e0f2fe;
    /* Sky 100 */
    --input-bg: #ffffff;
    --primary: #0ea5e9;
    /* Sky 500 - More harmonious blue */
    --primary-light: #e0f2fe;
    --shadow-color: rgba(14, 165, 233, 0.1);
    /* Blue tinted shadow */
}

[data-theme="light"] body {
    background-image: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    background-attachment: fixed;
}

[data-theme="light"] .nav {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    border-bottom-color: var(--border-color);
}

[data-theme="light"] .nav-brand,
[data-theme="light"] .nav-toggle {
    color: #0f172a;
}

[data-theme="light"] .sidebar {
    background: #ffffff;
    border-right-color: var(--border-color);
    color: #334155;
}

[data-theme="light"] .sidebar-brand {
    color: #0c4a6e;
    /* Sky 900 */
    border-bottom-color: var(--border-color);
    background: #f0f9ff;
}

[data-theme="light"] .nav-item {
    color: #64748b;
}

[data-theme="light"] .nav-item:hover,
[data-theme="light"] .nav-item.active {
    background: #e0f2fe;
    color: #0284c7;
    /* Sky 600 */
    border-radius: 6px;
    /* Enhanced look within sidebar */
}

[data-theme="light"] .card {
    box-shadow: 0 4px 6px -1px var(--shadow-color), 0 2px 4px -1px var(--shadow-color);
    border-color: var(--border-color);
}

[data-theme="light"] .mobile-header {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    border-bottom-color: var(--border-color);
}

[data-theme="light"] .mobile-header span,
[data-theme="light"] .menu-toggle {
    color: #0c4a6e;
}

[data-theme="light"] input,
[data-theme="light"] select,
[data-theme="light"] textarea {
    color: #1e293b;
    border-color: #cbd5e1;
    background: #f8fafc;
}

[data-theme="light"] input:focus,
[data-theme="light"] select:focus {
    background: #ffffff;
    border-color: #38bdf8;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

/* Smooth Transition */
body,
.sidebar,
.nav,
.card,
input,
select {
    transition: background-color 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        color 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        border-color 0.4s ease,
        box-shadow 0.4s ease;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    line-height: 1.5;

    /* Sticky Footer Setup */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

body>.container {
    flex: 1;
    /* Main content expands */
    width: 100%;
    /* Ensure full width */
    box-sizing: border-box;
    /* Include padding in width */
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.card {
    background: var(--card-bg);
    border-radius: 0.75rem;
    padding: 2rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

.btn {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    text-decoration: none;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

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

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

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

/* Theme Switch Slider */
.theme-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.theme-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #1e293b;
    /* Dark by default */
    transition: .4s;
    border-radius: 34px;
    border: 2px solid #334155;
}

.theme-slider:before {
    position: absolute;
    content: "🌙";
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.theme-slider {
    background-color: #0ea5e9;
    /* Sky Blue */
    border-color: #0284c7;
}

input:checked+.theme-slider:before {
    transform: translateX(26px);
    content: "☀️";
}

[data-theme="light"] .theme-slider {
    background-color: #e0f2fe;
    border-color: #bfdbfe;
}

[data-theme="light"] input:checked+.theme-slider:before {
    background-color: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

input:focus,
select:focus {
    outline: 2px solid var(--primary);
    border-color: transparent;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

th,
td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    font-weight: 600;
    color: #94a3b8;
}

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-box {
    width: 100%;
    max-width: 400px;
}

.nav {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    margin-bottom: 2rem;
}

.nav-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-color);
    text-decoration: none;
}

.nav-links a {
    color: #94a3b8;
    text-decoration: none;
    margin-left: 1.5rem;
    transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
    color: white;
}

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

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin-top: 0.5rem;
}

.badge {
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-pending {
    background: #334155;
    color: #e2e8f0;
}

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

.badge-billed {
    background: #0ea5e9;
    /* Sky 500 */
    color: white;
}

.badge-dispatched {
    background: #8b5cf6;
    /* Violet 500 */
    color: white;
}

.badge-delivered {
    background: var(--success);
    /* Green */
    color: white;
}

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

/* Mobile Utilities */
.mobile-only {
    display: none;
}

.desktop-only {
    display: table;
}

/* Mobile Responsive */
/* Mobile Responsive */
@media (max-width: 768px) {
    .container {
        padding: 0.3rem;
    }

    .nav {
        padding: 0;
        margin-bottom: 2rem;
        background: var(--card-bg);
        border-bottom: 1px solid var(--border-color);
    }

    .nav-content {
        flex-direction: column;
        padding: 0;
    }

    .nav-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 1rem;
        width: 100%;
        box-sizing: border-box;
    }

    .nav-toggle {
        background: none;
        border: none;
        color: var(--text-color);
        /* Use variable */
        cursor: pointer;
        padding: 0.5rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .nav-toggle:hover {
        background: rgba(125, 125, 125, 0.1);
        /* Neutral hover */
        border-radius: 0.375rem;
    }

    .nav-links {
        display: none;
        /* Hidden by default */
        flex-direction: column;
        width: 100%;
        border-top: 1px solid var(--border-color);
        background: var(--card-bg);
        /* Use variable instead of hardcoded dark */
        padding: 0;
        margin: 0 !important;
        /* Override previous margin hacks */
    }

    [data-theme="light"] .nav-links {
        background: white;
        border-top-color: #e2e8f0;
    }

    .nav-links.show {
        display: flex;
        /* Show when toggled */
    }

    .nav-links a {
        display: block;
        margin: 0;
        padding: 1rem 1.5rem;
        border-bottom: 1px solid var(--border-color);
        color: var(--text-color);
        /* Use variable */
        border-radius: 0;
        background: transparent;
        width: 100%;
        box-sizing: border-box;
    }

    .nav-links a:hover,
    .nav-links a.active {
        background: rgba(59, 130, 246, 0.1);
        color: var(--primary);
        padding-left: 2rem;
        /* Slide effect on hover */
    }

    /* Mobile Dashboard Cards - Enhanced Beautiful UI */
    .mobile-card-row {
        background: var(--card-bg);
        border: 1px solid var(--border-color);
        padding: 1.25rem;
        border-radius: 1rem;
        margin-bottom: 1rem;
        display: flex;
        flex-direction: column;
        gap: 0.85rem;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
        position: relative;
        overflow: hidden;
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }

    [data-theme="light"] .mobile-card-row {
        background: #ffffff;
        border-color: #e2e8f0;
        box-shadow: 0 4px 15px -3px rgba(14, 165, 233, 0.08);
    }

    .mobile-card-row:active {
        transform: scale(0.99);
    }

    .mobile-card-row::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        width: 4px;
        height: 100%;
        background: var(--primary);
        border-radius: 1rem 0 0 1rem;
        opacity: 0.8;
    }

    .mobile-card-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        padding-bottom: 0.5rem;
        border-bottom: 1px dashed var(--border-color);
    }

    .mobile-stats-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        background: var(--bg-color);
        padding: 0.75rem;
        border-radius: 0.5rem;
        gap: 0.5rem;
        margin: 0.5rem 0;
        border: 1px solid var(--border-color);
    }

    [data-theme="light"] .mobile-stats-grid {
        background: #f8fafc;
        border-color: #f1f5f9;
    }

    .mobile-stats-col {
        text-align: center;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }

    .mobile-stats-label {
        font-size: 0.7rem;
        color: #64748b;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        margin-bottom: 4px;
        font-weight: 600;
    }

    .mobile-stats-value {
        font-weight: 700;
        font-size: 1.1rem;
        color: var(--text-color);
    }

    .desktop-only {
        display: none;
    }

    .mobile-only {
        display: block;
    }
}

/* Desktop Navbar Tweaks */
@media (min-width: 769px) {
    .nav-toggle {
        display: none;
    }

    .nav-header {
        display: contents;
    }

    /* Allows logo to sit in flex flow */
}

/* ---------------------------------------------------- */
/* SALESMAN ORDER WIZARD (Moved from inline CSS)        */
/* ---------------------------------------------------- */

/* MODERN RESET & VARIABLES */
/* We integrate these with existing vars where possible */
:root {
    --primary-light: #eff6ff;
    --border-radius: 12px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* WIZARD CONTAINER */
.wizard-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 1rem 8rem 1rem;
    /* Bottom padding for sticky footer */
}

/* STEP INDICATOR - CONNECTED DOTS */
.step-indicator {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    position: relative;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.step-indicator::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 3px;
    background: #e2e8f0;
    z-index: 0;
    transform: translateY(-50%);
    border-radius: 99px;
}

.step {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: white;
    border: 2px solid #e2e8f0;
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    position: relative;
    z-index: 1;
    transition: var(--transition);
}

.step.active {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
    transform: scale(1.1);
}

.step.completed {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* MODERN INPUTS */
.form-control {
    width: 100%;
    padding: 1rem 1.25rem;
    font-size: 1rem;
    border: 1px solid #cbd5e1;
    border-radius: var(--border-radius);
    transition: var(--transition);
    background-color: white;
    color: #1e293b;
    appearance: none;
    /* Remove default browser styling */
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1.25rem center;
    background-size: 1rem;
}

/* PRODUCT SEARCH */
.search-wrapper {
    position: sticky;
    top: 1rem;
    z-index: 40;
    margin-bottom: 1.5rem;
    background: var(--bg-color);
    /* Matches body bg */
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.search-bar {
    width: 100%;
    padding: 1rem 1rem 1rem 3.5rem;
    border: 1px solid transparent;
    border-radius: 99px;
    font-size: 1rem;
    background: white;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.search-bar:focus {
    border-color: var(--primary);
    outline: none;
}

.search-icon {
    position: absolute;
    left: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
}

/* ACCORDION (Modernized) */
#nested-view {
    border: none !important;
    background: transparent !important;
    gap: 1rem;
    display: flex;
    flex-direction: column;
}

.accordion-item {
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    border: 1px solid #e2e8f0;
    box-shadow: var(--shadow-sm);
    margin-bottom: 0.5rem;
    transition: var(--transition);
}

.accordion-item.expanded {
    box-shadow: var(--shadow-md);
    border-color: #bfdbfe;
}

.accordion-header {
    background: white;
    padding: 1.25rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 1.05rem;
    color: #1e293b;
}

.accordion-content {
    background: #f8fafc;
    border-top: 1px solid #f1f5f9;
    display: none;
}

.accordion-item.expanded>.accordion-content {
    display: block;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* PRODUCT CARD */
.accordion-products {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
    padding: 1rem;
}

.product-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: var(--transition);
    gap: 1rem;
}

.product-card.has-qty {
    border-color: var(--primary);
    background-color: #f0f9ff;
    box-shadow: 0 0 0 1px var(--primary);
}

.product-info {
    flex: 1;
}

.product-name {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.25rem;
    color: #0f172a;
    line-height: 1.3;
}

.product-price {
    color: #64748b;
    font-weight: 500;
    font-size: 0.95rem;
}

.qty-control {
    display: flex;
    align-items: center;
    background: #f1f5f9;
    border-radius: 99px;
    padding: 0.25rem;
    gap: 0.5rem;
    border: 1px solid #e2e8f0;
}

.product-card.has-qty .qty-control {
    background: white;
    border-color: #bfdbfe;
}

.qty-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: bold;
    padding: 0;
    flex-shrink: 0;
    transition: var(--transition);
}

.qty-btn.minus {
    background: white;
    color: #64748b;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.qty-btn.minus:hover {
    background: #f1f5f9;
    color: #ef4444;
}

.qty-btn.plus {
    background: white;
    color: var(--primary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

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

.qty-val {
    font-weight: 700;
    min-width: 24px;
    text-align: center;
    font-size: 1rem;
    color: #0f172a;
}

/* SUMMARY BAR */
.summary-bar {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 2rem);
    max-width: 600px;
    /* ---------------------------------------------------- */
    /* ADMIN PANEL LAYOUT (Distributor)                     */
    /* ---------------------------------------------------- */

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

    .sidebar {
        width: 260px;
        background: #1e293b;
        color: #f1f5f9;
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        display: flex;
        flex-direction: column;
        border-right: 1px solid #334155;
        z-index: 50;
        overflow-y: auto;
        transition: transform 0.3s ease;
    }

    .sidebar-brand {
        padding: 1.5rem;
        font-size: 1.25rem;
        font-weight: 700;
        color: white;
        border-bottom: 1px solid #334155;
        text-decoration: none;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
    }

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

    .sidebar .nav-item {
        display: flex;
        align-items: center;
        padding: 0.75rem 1.5rem;
        color: #94a3b8;
        text-decoration: none;
        transition: all 0.2s;
        font-weight: 500;
    }

    .sidebar .nav-item:hover,
    .sidebar .nav-item.active {
        color: white;
        background: #334155;
    }

    .sidebar .nav-item i {
        width: 1.5rem;
        text-align: center;
        margin-right: 0.75rem;
    }

    .main-content {
        margin-left: 260px;
        flex: 1;
        min-height: 100vh;
        background: var(--bg-color);
        padding: 2rem;
        padding-bottom: 4rem;
        display: flex;
        flex-direction: column;
        width: calc(100% - 260px);
        transition: margin-left 0.3s ease, width 0.3s ease;
    }

    /* HEADER BAR FOR MOBILE */
    .mobile-header {
        display: none;
        background: #1e293b;
        padding: 1rem;
        align-items: center;
        justify-content: space-between;
        border-bottom: 1px solid #334155;
        margin-bottom: 1rem;
    }

    .menu-toggle {
        background: none;
        border: none;
        color: white;
        font-size: 1.5rem;
        cursor: pointer;
        padding: 0.25rem;
    }

    /* RESPONSIVE TABLE UTILITY */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 1rem;
        width: 100%;
    }

    /* MOBILE RESPONSIVE STYLES */
    @media (max-width: 768px) {
        .sidebar {
            transform: translateX(-100%);
            box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
        }

        .sidebar.show {
            transform: translateX(0);
        }

        .main-content {
            margin-left: 0;
            width: 100%;
            padding: 1rem;
        }

        .mobile-header {
            display: flex;
        }

        .app-layout {
            flex-direction: column;
        }

        /* Overlay when sidebar is open */
        .sidebar-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.5);
            z-index: 40;
        }

        .sidebar-overlay.show {
            display: block;
        }
    }

    border-radius: 1rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
}

.summary-bar>div:first-child {
    display: flex;
    flex-direction: column;
}

.summary-bar #total-display {
    color: #4ade80;
    /* Bright green */
    font-size: 1.4rem;
}

.summary-bar .btn {
    background: white;
    color: #0f172a;
    font-weight: 700;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    border: none;
}

.summary-bar .btn:hover {
    background: #f8fafc;
    transform: translateY(-2px);
}

/* UTILS */
.hidden {
    display: none !important;
}

@media (max-width: 600px) {
    .accordion-products {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        padding: 0.75rem;
    }

    .product-card {
        padding: 0.75rem;
    }

    .wizard-container {
        padding-bottom: 7rem;
    }
}

/* PREMIUM THEME TOGGLE */
.theme-toggle-premium {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    /* Glassy default */
    cursor: pointer;
    overflow: hidden;
    margin-left: 1rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle-premium:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.1);
}

.theme-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform-origin: center center;
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    /* Springy pop */
}

/* DARK MODE STATE (Default Body) -> Show SUN (to switch to light) or MOON (current state)? */
/* User asked for "Sun for Light mode, Moon for Dark mode" button state usually implies "Click to become X" or "Current is X". */
/* Let's follow standard: Show the icon representing the TARGET state (the one you switch TO). */
/* If Dark Mode: Show SUN (Light). */
/* If Light Mode: Show MOON (Dark). */

/* [data-theme="dark"] context */

/* Sun Icon */
[data-theme="dark"] .sun-icon {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
    color: #fbbf24;
    /* Amber 400 */
}

/* Moon Icon */
[data-theme="dark"] .moon-icon {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(90deg) scale(0.5);
    color: #94a3b8;
}

/* [data-theme="light"] context */

/* Sun Icon */
[data-theme="light"] .sun-icon {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-90deg) scale(0.5);
}

/* Moon Icon */
[data-theme="light"] .moon-icon {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
    color: #475569;
    /* Slate 600 */
}

/* Light Mode Override for Button Container */
[data-theme="light"] .theme-toggle-premium {
    border-color: #e2e8f0;
    background: white;
}

[data-theme="light"] .theme-toggle-premium:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.05);
}

/* AESTHETIC TOGGLE SLIDER */
.aesthetic-toggle {
    position: relative;
    display: inline-block;
    width: 64px;
    height: 32px;
    cursor: pointer;
}

.aesthetic-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-track {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #1e293b;
    /* Dark Slate (Dark Mode) */
    border-radius: 34px;
    transition: background-color 0.4s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 6px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.toggle-icon {
    z-index: 1;
    transition: opacity 0.3s ease;
}

.toggle-icon.sun {
    color: #f59e0b;
    /* Amber */
    opacity: 0;
    /* Hidden in Dark Mode (Thumb covers or transparent?) */
    transform: scale(0.8);
}

.toggle-icon.moon {
    color: #94a3b8;
    /* Slate */
    opacity: 1;
}

.toggle-thumb {
    position: absolute;
    height: 24px;
    width: 24px;
    left: 4px;
    /* Start Left (Dark Mode State?) Wait, logic check: Dark is default? */
    /* If checkbox is UNCHECKED (Dark), Thumb should be Left or Right? */
    /* Let's say Unchecked = Dark. Checked = Light. */
    /* Standard toggle: Left = Off/Dark, Right = On/Light. */
    bottom: 3px;
    background-color: #334155;
    /* Dark Thumb */
    border-radius: 50%;
    transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55), background-color 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Checked State (Light Mode) */
.aesthetic-toggle input:checked+.toggle-track {
    background-color: #bfdbfe;
    /* Sky 200 */
    border-color: #60a5fa;
}

.aesthetic-toggle input:checked+.toggle-track .toggle-thumb {
    transform: translateX(32px);
    background-color: #ffffff;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
    border-color: white;
}

/* TOGGLE SWITCH (Universal) */
.toggle-wrapper {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: background 0.2s;
    user-select: none;
    border: 1px solid transparent;
}

.toggle-wrapper:hover {
    background: rgba(226, 232, 240, 0.5);
    border-color: #cbd5e1;
}

.toggle-input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.toggle-slider {
    position: relative;
    width: 44px;
    height: 24px;
    background-color: #cbd5e1;
    border-radius: 99px;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.toggle-slider:before {
    content: "";
    position: absolute;
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    border-radius: 50%;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.toggle-input:checked+.toggle-slider {
    background-color: var(--primary);
}

.toggle-input:checked+.toggle-slider:before {
    transform: translateX(20px);
}

.toggle-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-color);
}

.aesthetic-toggle input:checked+.toggle-track .toggle-icon.sun {
    opacity: 1;
}

.aesthetic-toggle input:checked+.toggle-track .toggle-icon.moon {
    opacity: 0;
}

/* ---------------------------------------------------- */
/* ---------------------------------------------------- */
/* ADMIN PANEL LAYOUT (Distributor)                     */
/* ---------------------------------------------------- */

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

.sidebar {
    width: 260px;
    background: #1e293b;
    color: #f1f5f9;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #334155;
    z-index: 100;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    padding: 1.5rem;
    font-size: 1.25rem;
    font-weight: 800;
    color: white;
    background: rgba(0, 0, 0, 0.2);
    /* Subtle dimming header */
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    letter-spacing: -0.025em;
}

.sidebar-nav {
    padding: 1rem 0.5rem;
    /* Add horizontal padding for contained items */
    flex-grow: 1;
}

.sidebar .nav-item {
    display: flex;
    align-items: center;
    padding: 0.875rem 1rem;
    color: #94a3b8;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    border-radius: 0.5rem;
    /* Rounded corners */
    margin-bottom: 0.25rem;
}

.sidebar .nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #f1f5f9;
}

.sidebar .nav-item.active {
    color: white;
    background: var(--primary);
    /* Bright active state */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
}

.sidebar .nav-item i {
    width: 1.5rem;
    text-align: center;
    margin-right: 0.75rem;
    opacity: 0.8;
}

.main-content {
    margin-left: 260px;
    flex: 1;
    min-height: 100vh;
    background: var(--bg-color);
    padding: 2rem;
    padding-bottom: 4rem;
    display: flex;
    flex-direction: column;
    width: calc(100% - 260px);
    transition: margin-left 0.3s ease, width 0.3s ease;
}

/* HEADER BAR FOR MOBILE */
/* HEADER BAR FOR MOBILE */
.mobile-header {
    display: none;
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.98) 0%, rgba(30, 41, 59, 0.85) 100%);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 1rem 1.25rem;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 0;

    /* Sticky Fix */
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 4px 20px -5px rgba(0, 0, 0, 0.2);
}

.mobile-header-spacer {
    width: 40px;
}

.mobile-brand {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.menu-toggle {
    background: transparent;
    border: none;
    color: #f8fafc;
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.menu-toggle:active {
    transform: scale(0.9);
    color: var(--primary);
}

.menu-toggle svg {
    width: 26px;
    height: 26px;
    stroke-width: 2.5;
}

/* RESPONSIVE TABLE UTILITY */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
    width: 100%;

    /* Card-like look for table wrapper */
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
}

/* Better Table for Mobile */
.table-responsive table {
    margin-top: 0;
    /* Removing top margin to flush with wrapper */
}

.table-responsive th {
    white-space: nowrap;
    padding: 0.5rem 0.5rem;
    font-weight: 600;
}

.table-responsive td {
    white-space: normal;
    word-break: break-word;
    padding: 0.5rem 0.5rem;
    vertical-align: top;
}

/* MOBILE RESPONSIVE STYLES */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-105%);
        box-shadow: 10px 0 25px -5px rgba(0, 0, 0, 0.5);
        /* Deeper shadow */
        width: 280px;
        /* Slightly wider for better touch */
        max-width: 80vw;
        border-right: 1px solid rgba(255, 255, 255, 0.05);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 1.5rem 1rem;
        /* More top/bottom padding */
    }

    .mobile-header {
        display: flex;
    }

    .app-layout {
        flex-direction: column;
    }

    h1 {
        font-size: 1.75rem;
        /* Larger, bolder title */
        font-weight: 800;
        letter-spacing: -0.03em;
        margin-bottom: 1.25rem;
        /* Add subtle gradient text? Optional, let's keep it clean white */
    }

    /* Refined Overlay */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(15, 23, 42, 0.6);
        /* Darker overlay */
        z-index: 45;
        /* Below Sidebar (50) but above Header (40) - WAIT, Header is 50.Sidebar 50. */
        /* Let's promote Sidebar to 60 */
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .sidebar-overlay.show {
        display: block;
        opacity: 1;
    }

    /* Card Polish on Mobile */
    .card {
        border: 1px solid rgba(255, 255, 255, 0.06);
        background: linear-gradient(145deg, #1e293b 0%, #151e2e 100%);
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
    }

    /* ---------------------------------------------------- */
    /* MOBILE CARD TABLE VIEW (The "Perfect" Table)         */
    /* ---------------------------------------------------- */

    /* Remove wrapper border/padding for cleaner look */
    .table-responsive {
        border: none;
        border-radius: 0;
        margin-bottom: 0;
        overflow: visible;
        /* Allow shadows to pop */
    }

    .mobile-card-table,
    .mobile-card-table tbody,
    .mobile-card-table tr {
        display: block;
        width: 100%;
    }

    .mobile-card-table thead {
        display: none;
        /* Hide standard headers */
    }

    .mobile-card-table tbody tr {
        display: flex;
        flex-direction: column;
        margin-bottom: 0.75rem;
        background: rgba(30, 41, 59, 1);
        border: 1px solid rgba(255, 255, 255, 0.05);
        border-radius: 0.75rem;
        padding: 1rem;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
        position: relative;
    }

    .mobile-card-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.25rem 0;
        border: none;
        text-align: right;
        min-height: 1.75rem;
        order: 10;

        /* Fix Overflow */
        word-break: break-word;
        overflow-wrap: break-word;
        white-space: normal;
    }

    /* CARD TITLE LOGIC (Name/Party becomes Header) */
    .mobile-card-table td[data-label="Party"],
    .mobile-card-table td[data-label="Name"],
    .mobile-card-table td[data-label="Product Name"],
    .mobile-card-table td[data-label="Shop Name"] {
        order: -5;
        /* Move to top */
        display: block;
        text-align: left;
        font-size: 1rem;
        font-weight: 700;
        color: #f8fafc;

        /* True Card Header Style */
        background: rgba(255, 255, 255, 0.05);
        /* Proper header bg */
        margin: -1rem -1rem 0.75rem -1rem;
        /* Pull to edges */
        padding: 0.75rem 1rem;
        /* Header padding */
        width: calc(100% + 2rem);
        /* Full width */
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        border-radius: 0.75rem 0.75rem 0 0;
        /* Rounded top */
        text-transform: uppercase;
        letter-spacing: 0.025em;
    }

    .mobile-card-table td[data-label="Party"]::before,
    .mobile-card-table td[data-label="Name"]::before,
    .mobile-card-table td[data-label="Product Name"]::before,
    .mobile-card-table td[data-label="Shop Name"]::before {
        display: none;
    }

    /* HIDE IDs on Mobile */
    .mobile-card-table td[data-label*="ID"] {
        display: none !important;
    }

    .mobile-card-table td:last-child {
        order: 100;
        border-bottom: none;
        padding-top: 1.5rem;
        /* More breathing room for buttons */
        display: block;
        text-align: right;
    }

    /* Make buttons full width grid */
    .mobile-card-table td:last-child>div {
        display: grid !important;
        /* Force Grid on Mobile */
        grid-template-columns: repeat(2, 1fr) !important;
        /* Force 2 columns */
        gap: 0.75rem !important;
        /* Better gap */
    }

    .mobile-card-table td:last-child form {
        grid-column: span 1;
    }

    /* Ensure delete button in form takes full width of its grid cell */
    .mobile-card-table td:last-child form button {
        width: 100% !important;
    }

    /* Bigger Buttons on Mobile */
    .mobile-card-table .btn {
        padding: 0.6rem !important;
        font-size: 0.9rem !important;
        border-radius: 0.5rem;
        width: 100%;
        /* Fill grid cell */
    }

    /* The 'Label' from data attribute */
    .mobile-card-table td::before {
        content: attr(data-label);
        font-weight: 600;
        text-transform: uppercase;
        font-size: 0.75rem;
        /* Slightly larger readable label */
        color: #94a3b8;
        /* Soft slate color */
        letter-spacing: 0.05em;
        margin-right: 1.5rem;
        text-align: left;
        flex: 1;
    }

    .mobile-card-table td:last-child::before {
        display: none;
    }

    .mobile-card-table .badge {
        font-size: 0.75rem;
        padding: 0.25em 0.6em;
    }

    .mobile-card-table input[type="number"],
    .mobile-card-table input[type="text"] {
        width: 100px;
        text-align: right;
        padding: 0.4rem;
        font-size: 1rem;
    }
}