:root {
    --primary: #2563EB;
    --primary-dark: #1D4ED8;
    --bg: #F4F5F9;
    --surface: #FFFFFF;
    --text-main: #111827;
    --text-muted: #4B5563;
    --border: #E5E7EB;
    --warning: #F5A623;
    --success: #10B981;
    --danger: #EF4444;
}

/* Dropdown Settings */
.dropdown { position: relative; display: inline-block; }
.dropdown-content {
    display: none;
    position: absolute;
    background-color: white;
    min-width: 180px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    z-index: 200;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid #E2E8F0;
    margin-top: 8px;
}
.dropdown-content.show { display: block; }
.dropdown-content a {
    color: #1E293B;
    padding: 12px 16px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}
.dropdown-content a:hover { background-color: #F8FAFC; }

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

/* Hide scrollbars globally but keep functionality */
*::-webkit-scrollbar {
    display: none;
}
* {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

body {
    background-color: var(--bg);
    color: var(--text-main);
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ===== VIEWS SYSTEM ===== */
div[id$="-view-container"] {
    display: contents;
}
.view {
    display: none;
    flex: 1;
    height: 100%;
    flex-direction: column;
    overflow-y: auto;
    padding-bottom: 70px;
}

.view.active {
    display: flex;
}
#main-content{
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

/* ===== DEFAULT HEADER (Home & Return) ===== */
.default-header {
    background-color: var(--surface);
    padding: 16px 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 10;
}

.default-header h1 {
    font-size: 20px;
    font-weight: 600;
}

.default-content {
    padding: 20px;
}

.card {
    background: var(--surface);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    border: 1px solid var(--border);
}

/* ===== SALES VIEW ===== */
#sales-view {
    background-color: var(--bg);
    padding-bottom: 0; 
}

.sales-header-container {
    color: white;
    position: sticky;
    top: 0;
    z-index: 20;
}
/* View-specific backgrounds */
#sales-view .sales-header-container, 
#users-view .sales-header-container,
#products-view .sales-header-container,
#clients-view .sales-header-container,
#suppliers-view .sales-header-container,
#warehouses-view .sales-header-container { background-color: var(--primary); }
#return-view .sales-header-container { background-color: var(--warning); }
#purchase-view .sales-header-container { background-color: var(--success); }
#purchase-return-view .sales-header-container { background-color: #9333EA; }


.sales-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
}

.title-group {
    display: flex;
    align-items: center;
    gap: 16px;
}

.title-group i {
    font-size: 20px;
    cursor: pointer;
}

.title-group h2 {
    font-size: 18px;
    font-weight: 600;
}

.actions {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 18px;
}

.search-wrapper {
    background-color: transparent;
    padding: 0 16px 12px 16px;
    position: relative;
    margin-top: -6px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.search-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 24px;
    background-color: inherit; /* This will be overridden by inline styles / specific views */
    z-index: 0;
}

/* View-specific search wrapper backgrounds */
#return-view .search-wrapper::before { background-color: var(--warning); }
#purchase-view .search-wrapper::before { background-color: var(--success); }
#purchase-return-view .search-wrapper::before { background-color: #9333EA; }

.search-box {
    background-color: white;
    border-radius: 8px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    position: relative;
    z-index: 1;
    flex: 1;
    min-width: 0;
}

.search-box i {
    color: var(--text-muted);
    font-size: 16px;
}

.search-box input {
    border: none;
    outline: none;
    width: 100%;
    font-size: 15px;
    color: var(--text-main);
    background: transparent;
}

.search-box input::placeholder {
    color: #A0AEC0;
}

/* Timeline / List Area */
.sales-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px 16px 120px 28px;
    position: relative;
}

.timeline-line {
    position: absolute;
    left: 32px;
    top: 24px;
    bottom: 120px;
    width: 1px;
    background-color: #DEE2E6;
    z-index: 0;
}

.date-header {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    margin-left: -19px; 
    position: relative;
    z-index: 1;
    margin-top: 10px;
}

.date-dot {
    width: 14px;
    height: 14px;
    background-color: var(--primary);
    border-radius: 50%;
    border: 3px solid #DBEAFE; 
    margin-right: 12px;
    box-shadow: 0 0 0 2px var(--bg);
}

.date-text {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-main);
}

.sales-card {
    background: white;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 12px;
    margin-left: 12px;
    position: relative;
    z-index: 1;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.sc-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.sc-client-name {
    font-weight: 500;
    font-size: 15px;
    color: var(--text-main);
    margin-bottom: 4px;
}

.sc-client-id {
    font-size: 13px;
    color: #C1C9D2;
}

.sc-amount {
    font-weight: 600;
    font-size: 15px;
    text-align: right;
    color: var(--text-main);
}

.sc-currency {
    font-weight: 400;
    font-size: 13px;
    color: var(--text-muted);
    margin-left: 4px;
}

.sc-bottom {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.badge {
    padding: 5px 14px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 500;
    color: white;
}
.badge-warning { background-color: var(--warning); }
.badge-success { background-color: var(--success); }
.badge-danger { background-color: var(--danger); }
.badge-secondary { background-color: #6B7280; }

.sc-time {
    font-size: 12px;
    color: #A0AEC0;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Add Sale Button (FAB) */
.fab-container {
    position: fixed;
    bottom: 85px; 
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    z-index: 100;
    pointer-events: none;
}
.fab-menu {
    pointer-events: auto;
}

.fab-button {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
    pointer-events: auto;
    cursor: pointer;
    transition: transform 0.2s;
}

.fab-button:active {
    transform: scale(0.95);
}

/* ===== BOTTOM NAV ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--surface);
    display: flex;
    justify-content: space-around;
    padding: 10px;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    z-index: 40;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    gap: 4px;
    flex: 1;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.nav-item i {
    font-size: 20px;
    transition: all 0.2s ease;
    margin-bottom: 2px;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item.active i {
    transform: translateY(-2px);
}

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100%;
    background-color: var(--surface);
    z-index: 100;
    transition: left 0.3s ease;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
}

.sidebar.open {
    left: 0;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0,0,0,0.5);
    z-index: 90;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #000000;
}

.sidebar-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

.sidebar-header i {
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
}

.sidebar-menu {
    padding: 16px 0;
    flex: 1;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.sidebar-item {
    display: flex;
    align-items: center;
    padding: 14px 24px;
    color: var(--text-main);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    gap: 16px;
    transition: background-color 0.2s;
}

.sidebar-item:active {
    background-color: var(--bg);
}

.sidebar-item i {
    font-size: 18px;
    color: var(--text-muted);
    width: 24px;
    text-align: center;
}

/* TOAST NOTIFICATION */
.toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 90%;
    pointer-events: none;
}

.toast {
    background: #312E81;
    color: white;
    padding: 12px 20px;
    border-radius: 12px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastIn 0.3s ease-out forwards, toastOut 0.3s ease-in 2.7s forwards;
    opacity: 0;
}

.toast.success { background: var(--success); }
.toast.error { background: #EF4444; }
.toast.warning { background: var(--warning); }

@keyframes toastIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes toastOut {
    from { transform: translateY(0); opacity: 1; }
    to { transform: translateY(-20px); opacity: 0; }
}
/* ===== CUSTOM MULTI-SELECT ===== */
.multi-select-container {
    position: relative;
    width: 100%;
}

.multi-select-display {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: white;
    font-size: 14px;
    color: var(--text-main);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.multi-select-display.open {
    border-color: var(--primary);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.multi-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border);
    border-top: none;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.multi-select-container.open .multi-select-dropdown {
    display: block;
}

.multi-select-option {
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid var(--bg);
}

.multi-select-option:last-child {
    border-bottom: none;
}

.multi-select-option:hover {
    background-color: var(--bg);
}

.multi-select-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

.filter-toggle-btn {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    z-index: 1;
    transition: background 0.2s;
}

.filter-toggle-btn.active {
    background-color: white;
    color: var(--primary);
}

/* Filter Modal Styles */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1000;
}

.filter-modal {
    display: none;
    position: fixed;
    bottom: -100%;
    left: 0;
    width: 100%;
    background: white;
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.2);
    z-index: 1001;
    transition: bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

@media (min-width: 600px) {
    .filter-modal {
        width: 380px;
        height: 100%;
        max-height: 100vh;
        right: -380px;
        left: auto;
        top: 0;
        bottom: 0;
        border-radius: 0;
        transform: none;
        opacity: 1;
        visibility: visible;
        transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .filter-modal.active {
        right: 0;
        transform: none;
    }
    .filter-modal-body {
        grid-template-columns: 1fr; /* Single column for sidebar */
    }
    .filter-modal-body .filter-group {
        grid-column: span 1 !important;
    }
}

.filter-modal.active {
    bottom: 0;
}

.filter-modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.filter-modal-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
}

.filter-modal-header i {
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
}

.filter-modal-body {
    padding: 16px 20px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.filter-modal-body .filter-group {
    grid-column: span 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-modal-body .filter-group.full-width {
    grid-column: span 2;
}

.filter-modal-body label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin: 0;
    line-height: 1;
}

.filter-modal-body input[type="date"],
.filter-modal-body select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    color: var(--text-main);
    background: #F9FAFB;
    outline: none;
    transition: all 0.2s;
    box-sizing: border-box;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.filter-modal-body select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236B7280'%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 12px center;
    background-size: 16px;
    padding-right: 40px;
}

.filter-modal-body input:focus,
.filter-modal-body select:focus {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.filter-modal-footer {
    padding: 16px 20px 24px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
}

.filter-modal-footer button {
    flex: 1;
    padding: 14px;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-modal-footer button:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: #F3F4F6;
    color: var(--text-main);
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}


/* Adjust search wrapper for modal */
.filter-toggle-btn.has-active-filters {
    background-color: var(--warning);
    color: white;
}

/* Checkbox inside modal */
.filter-checkbox-group {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
}

.filter-checkbox-group input {
    width: 22px;
    height: 22px;
    cursor: pointer;
    accent-color: var(--primary);
}

.filter-checkbox-group label {
    font-size: 14px;
    color: var(--text-main);
    font-weight: 500;
    cursor: pointer;
    line-height: normal;
}
/* ===== CONFIRMATION MODAL ===== */
.confirm-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 90%;
    max-width: 400px;
    background: var(--surface);
    border-radius: 20px;
    padding: 24px;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    opacity: 0;
    transition: all 0.3s ease;
}

.confirm-modal.active {
    display: flex;
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.confirm-modal-icon {
    width: 64px;
    height: 64px;
    background-color: #FEE2E2;
    color: var(--danger);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    margin-bottom: 16px;
}

.confirm-modal-content h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 8px;
}

.confirm-modal-content p {
    font-size: 15px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 24px;
}

.confirm-modal-footer {
    display: flex;
    gap: 12px;
    width: 100%;
}

.confirm-modal-footer button {
    flex: 1;
    padding: 12px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.confirm-modal-footer .btn-secondary {
    background-color: #F3F4F6;
    color: var(--text-main);
}

.confirm-modal-footer .btn-danger {
    background-color: var(--danger);
    color: white;
}

.confirm-modal-footer button:active {
    transform: scale(0.98);
}
