/* CSS Variables */
:root {
    --primary-color: #1e3a5f;
    --primary-hover: #152a45;
    --primary-light: #e8f4fc;
    --secondary-color: #c9a227;
    --accent-color: #2980b9;
    --success-color: #28a745;
    
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    
    --border-color: #e2e8f0;
    --border-radius: 12px;
    --border-radius-lg: 16px;
    --border-radius-sm: 8px;
    
    --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);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
}

/* Utility Classes */
.text-success { color: var(--success-color) !important; }
.text-muted { color: var(--text-muted) !important; }

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* App Container */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: #1a1a1a;
    border-bottom: 1px solid #333;
    padding: 0.6rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-right {
    display: flex;
    align-items: center;
}

.logo-img {
    height: 40px;
    width: auto;
    object-fit: contain;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    padding: 0 1.5rem;
}

/* Hero Search Section */
.hero-search {
    padding: 1.5rem 0;
    text-align: center;
}

.hero-content h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
    background: linear-gradient(135deg, var(--text-primary), var(--primary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-content p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 1.25rem;
}

/* Global Search */
.global-search-container {
    max-width: 700px;
    margin: 0 auto;
    position: relative;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box .search-icon {
    position: absolute;
    left: 1.25rem;
    color: var(--text-muted);
    font-size: 1.25rem;
    transition: color var(--transition-fast);
}

.search-box input {
    width: 100%;
    padding: 0.9rem 3rem;
    font-size: 0.95rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    background: var(--bg-secondary);
    color: var(--text-primary);
    outline: none;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-md);
}

.search-box input:focus {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-lg), 0 0 0 4px var(--primary-light);
}

.search-box input:focus + .search-icon,
.search-box input:focus ~ .search-icon {
    color: var(--primary-color);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.clear-btn {
    position: absolute;
    right: 1rem;
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-tertiary);
    border-radius: 50%;
    color: var(--text-muted);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.clear-btn.visible {
    display: flex;
}

.clear-btn:hover {
    background: var(--secondary-color);
    color: white;
}

/* Search Suggestions */
.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-top: 0.5rem;
    max-height: 400px;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    z-index: 50;
    display: none;
}

.search-suggestions.active {
    display: block;
}

.suggestion-group {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.suggestion-group:last-child {
    border-bottom: none;
}

.suggestion-group-title {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.suggestion-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: background var(--transition-fast);
}

.suggestion-item:hover {
    background: var(--bg-tertiary);
}

.suggestion-item.keyboard-active {
    background: var(--primary-light);
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
}

.suggestion-item i {
    color: var(--primary-color);
    width: 20px;
    text-align: center;
}

.suggestion-item .highlight {
    background: var(--primary-light);
    color: var(--primary-color);
    padding: 0 2px;
    border-radius: 2px;
}

.suggestion-item .category-badge {
    margin-left: auto;
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    background: var(--bg-tertiary);
    border-radius: 20px;
    color: var(--text-muted);
}

/* Filter Section */
.filter-section {
    background: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    padding: 1rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

/* Calculator Section */
.calculator-section {
    background: linear-gradient(135deg, var(--primary-color) 0%, #2d4a6f 100%);
    border-radius: var(--border-radius-lg);
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-lg);
    color: white;
}

.calculator-header {
    margin-bottom: 0.75rem;
}

.calculator-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: white;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.calculator-header h3 i {
    color: var(--secondary-color);
}

.calculator-controls {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.calc-input-group {
    flex: 0 0 auto;
    min-width: 140px;
}

.calc-input-group label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: rgba(255,255,255,0.85);
    margin-bottom: 0.35rem;
}

.calc-input-group label i {
    color: var(--secondary-color);
}

.calc-input-group input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: var(--border-radius-sm);
    background: rgba(255,255,255,0.1);
    color: white;
    outline: none;
    transition: all var(--transition-fast);
}

.calc-input-group input:focus {
    border-color: var(--secondary-color);
    background: rgba(255,255,255,0.15);
}

.calc-input-group input::placeholder {
    color: rgba(255,255,255,0.5);
}

.calc-input-group .select-wrapper select {
    background: rgba(255,255,255,0.1);
    border: 2px solid rgba(255,255,255,0.2);
    color: white;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
}

.calc-input-group .select-wrapper select:focus {
    border-color: var(--secondary-color);
}

.calc-input-group .select-wrapper select option {
    background: var(--primary-color);
    color: white;
}

.calc-input-group .select-wrapper .select-arrow {
    color: rgba(255,255,255,0.7);
}

.calc-result-group {
    flex: 0 0 auto;
    min-width: 160px;
}

.calc-result-group label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: rgba(255,255,255,0.85);
    margin-bottom: 0.35rem;
}

.calc-result-group label i {
    color: var(--secondary-color);
}

.calc-result {
    background: var(--secondary-color);
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-sm);
    font-weight: 700;
    font-size: 1.1rem;
    color: #1a1a1a;
    text-align: center;
    min-width: 120px;
}

.calc-variant-info {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.calc-variant-info .variant-label {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.7);
    font-style: italic;
}

.calc-variant-info .variant-name {
    font-size: 0.85rem;
    color: white;
    font-weight: 600;
    background: rgba(255,255,255,0.15);
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
}

/* Material Requirements Section */
.material-requirements {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255,255,255,0.2);
}

.material-requirements-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.material-header-left h4 {
    font-size: 0.85rem;
    font-weight: 600;
    color: white;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 0.5rem 0;
}

.material-header-left h4 i {
    color: var(--secondary-color);
}

.shade-name-display {
    margin-top: 0.25rem;
}

.shade-name-display .shade-name {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.8);
    font-weight: 500;
}

.shade-name-display .shade-name strong {
    color: var(--secondary-color);
    font-weight: 600;
}

.material-header-right {
    margin-left: auto;
}

.btn-print {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-print:hover {
    background: #8a5fb8;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(118, 75, 162, 0.3);
}

.btn-print i {
    font-size: 0.75rem;
}

.btn-save-lead {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s;
    text-decoration: none;
    margin-right: 8px;
}

.btn-save-lead:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.material-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.material-requirements-table {
    overflow-x: auto;
    border-radius: var(--border-radius-sm);
    background: rgba(255,255,255,0.1);
}

.material-requirements-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.material-requirements-table th {
    padding: 0.6rem 0.75rem;
    text-align: left;
    background: rgba(0,0,0,0.2);
    color: rgba(255,255,255,0.9);
    font-weight: 600;
    white-space: nowrap;
}

.material-requirements-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.9);
}

.material-requirements-table tr:last-child td {
    border-bottom: none;
}

.material-requirements-table .material-name {
    font-weight: 500;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.material-requirements-table .material-base-qty,
.material-requirements-table .material-required-qty {
    text-align: right;
    font-family: 'Courier New', monospace;
}

.material-requirements-table .material-required-qty {
    color: var(--secondary-color);
}

.material-requirements-table .material-unit {
    text-align: center;
}

.material-requirements-table .material-packaging {
    white-space: nowrap;
}

.material-requirements-table .material-cost {
    text-align: right;
    font-weight: 600;
    color: var(--secondary-color);
    white-space: nowrap;
}

.material-requirements-table .material-total-row {
    background: rgba(0,0,0,0.3) !important;
    border-top: 2px solid var(--secondary-color);
}

.material-requirements-table .material-total-row td {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

.material-requirements-table .text-right {
    text-align: right;
}

.material-requirements-table .pkg-item {
    display: inline-block;
    background: var(--secondary-color);
    color: #1a1a1a;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.75rem;
    margin: 1px;
    cursor: help;
}

.material-requirements-table .pkg-remainder {
    display: inline-block;
    background: rgba(255,255,255,0.2);
    color: white;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-weight: 500;
    font-size: 0.75rem;
    font-style: italic;
    margin: 1px;
    cursor: help;
}

.filter-header {
    margin-bottom: 0.75rem;
}

.filter-header h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.filter-header h3 i {
    color: var(--primary-color);
}

.filter-controls {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.filter-group {
    flex: 1;
    min-width: 220px;
}

.filter-group label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

.filter-group label i {
    color: var(--primary-color);
}

.select-wrapper {
    position: relative;
}

.select-wrapper select {
    width: 100%;
    padding: 0.6rem 2rem 0.6rem 0.75rem;
    font-size: 0.85rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    appearance: none;
    outline: none;
    transition: all var(--transition-fast);
}

.select-wrapper select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.select-wrapper select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.select-wrapper .select-arrow {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    transition: transform var(--transition-fast);
}

/* Searchable Select Dropdown */
.searchable-select {
    position: relative;
}

.searchable-select input {
    width: 100%;
    padding: 0.6rem 2rem 0.6rem 0.75rem;
    font-size: 0.85rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: text;
    outline: none;
    transition: all var(--transition-fast);
}

.searchable-select input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.searchable-select input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: var(--bg-tertiary);
}

.searchable-select .select-arrow {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    transition: transform var(--transition-fast);
    font-size: 0.75rem;
}

.searchable-select.open .select-arrow {
    transform: translateY(-50%) rotate(180deg);
}

.dropdown-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 2px solid var(--primary-color);
    border-top: none;
    border-radius: 0 0 var(--border-radius-sm) var(--border-radius-sm);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    box-shadow: var(--shadow-lg);
}

.dropdown-list.active {
    display: block;
}

.dropdown-item {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background var(--transition-fast);
    border-bottom: 1px solid var(--border-color);
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover,
.dropdown-item.selected {
    background: var(--primary-light);
    color: var(--primary-color);
}

.dropdown-item.keyboard-active {
    background: var(--primary-light);
    color: var(--primary-color);
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
}

.dropdown-item.no-results {
    color: var(--text-muted);
    font-style: italic;
    cursor: default;
}

.dropdown-item.no-results:hover {
    background: transparent;
    color: var(--text-muted);
}

.reset-filters-btn {
    padding: 0.6rem 1rem;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all var(--transition-fast);
}

.reset-filters-btn:hover {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
    color: white;
}

/* Stats Bar */
.stats-bar {
    display: flex;
    gap: 1.5rem;
    padding: 0.6rem 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.stat-item i {
    color: var(--primary-color);
}

.stat-item span {
    font-weight: 700;
    color: var(--text-primary);
}

/* Results Container */
.results-container {
    min-height: 300px;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
}

.empty-icon {
    width: 80px;
    height: 80px;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.empty-icon i {
    font-size: 2rem;
    color: var(--primary-color);
}

.empty-state h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.empty-state p {
    color: var(--text-secondary);
}

/* Formulation Cards */
.formulation-grid {
    display: grid;
    gap: 1rem;
}

.formulation-card {
    background: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
}

.formulation-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.card-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    padding: 0.85rem 1rem;
    color: white;
}

.card-header .category-name {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.9;
    margin-bottom: 0.15rem;
}

.card-header .product-name {
    font-size: 1rem;
    font-weight: 700;
}

.card-body {
    padding: 1rem;
}

/* Formulation Table */
.formulation-table {
    width: 100%;
    border-collapse: collapse;
}

.formulation-table thead th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border-bottom: 2px solid var(--border-color);
}

.formulation-table tbody td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
}

.formulation-table tbody tr:last-child td {
    border-bottom: none;
}

.formulation-table tbody tr:hover {
    background: var(--bg-tertiary);
}

.formulation-table .sr-num {
    color: var(--text-muted);
    font-weight: 500;
    width: 50px;
}

.formulation-table .product-col {
    font-weight: 500;
    color: var(--text-primary);
}

.formulation-table .qty-col {
    color: var(--primary-color);
    font-weight: 600;
}

.formulation-table .unit-col {
    color: var(--text-secondary);
}

.formulation-table .rate-col {
    color: var(--text-secondary);
    text-align: right;
}

.formulation-table .total-col {
    color: var(--secondary-color);
    font-weight: 700;
    text-align: right;
}

/* Card Header with Total */
.card-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    padding: 0.85rem 1rem;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.card-header-left {
    flex: 1;
}

.card-header-right {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
}

.card-header .variant-total {
    font-size: 1.1rem;
    font-weight: 700;
    background: rgba(255,255,255,0.2);
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
}

.card-header .variant-total-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.85;
}

.card-header .calc-icon-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    font-size: 0.75rem;
}

.card-header .calc-icon-btn:hover {
    background: rgba(255,255,255,0.35);
    transform: scale(1.1);
}

/* Table Footer for Totals */
.formulation-table tfoot td {
    padding: 0.6rem 0.75rem;
    font-weight: 700;
    background: var(--bg-tertiary);
    border-top: 2px solid var(--border-color);
}

.formulation-table tfoot .total-label {
    text-align: right;
    color: var(--text-primary);
}

.formulation-table tfoot .grand-total {
    color: var(--primary-color);
    font-size: 1rem;
    text-align: right;
}

/* Category Section */
.category-section {
    margin-bottom: 2.5rem;
}

.category-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--primary-color);
}

.category-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.category-header .product-count {
    background: var(--primary-color);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
}

/* No Results */
.no-results {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.no-results i {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.loading-overlay.active {
    display: flex;
}

.loader {
    background: var(--bg-secondary);
    padding: 2rem 3rem;
    border-radius: var(--border-radius-lg);
    text-align: center;
    box-shadow: var(--shadow-xl);
}

.loader-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Footer */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: auto;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.formulation-card {
    animation: fadeIn 0.3s ease forwards;
}

.formulation-card:nth-child(2) { animation-delay: 0.05s; }
.formulation-card:nth-child(3) { animation-delay: 0.1s; }
.formulation-card:nth-child(4) { animation-delay: 0.15s; }
.formulation-card:nth-child(5) { animation-delay: 0.2s; }

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Responsive Design */
@media (max-width: 768px) {
    .header {
        padding: 1rem;
    }
    
    .logo-text h1 {
        font-size: 1.25rem;
    }
    
    .main-content {
        padding: 0 1rem;
    }
    
    .hero-content h2 {
        font-size: 1.75rem;
    }
    
    .hero-content p {
        font-size: 1rem;
    }
    
    .calculator-controls {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .calc-input-group,
    .calc-result-group {
        min-width: 100%;
    }
    
    .calc-variant-info {
        justify-content: center;
    }
    
    .filter-controls {
        flex-direction: column;
        gap: 1rem;
    }
    
    .filter-group {
        min-width: 100%;
    }
    
    .reset-filters-btn {
        width: 100%;
        justify-content: center;
    }
    
    .stats-bar {
        flex-wrap: wrap;
        gap: 1rem;
    }
    
    /* Paint shade card table horizontal scroll */
    .formulation-card .card-body {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .formulation-table {
        font-size: 0.8rem;
        min-width: 500px;
    }
    
    .formulation-table thead th,
    .formulation-table tbody td {
        padding: 0.4rem 0.5rem;
        white-space: nowrap;
    }
    
    .formulation-table tfoot td {
        padding: 0.4rem 0.5rem;
    }
    
    .card-header {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .card-header-right {
        flex-direction: row;
        align-items: center;
        width: 100%;
        justify-content: space-between;
    }
    
    /* Material Requirements Table Mobile */
    .material-requirements-header {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
    
    .material-header-left {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .material-header-left h4 {
        font-size: 14px;
    }
    
    .shade-name-display {
        font-size: 12px;
        padding: 4px 8px;
    }
    
    .material-header-right {
        display: flex;
        gap: 8px;
        width: 100%;
    }
    
    .material-header-right .btn {
        flex: 1;
        padding: 10px 8px;
        font-size: 12px;
        justify-content: center;
    }
    
    .material-header-right .btn i {
        margin-right: 4px;
    }
    
    /* Horizontal scroll for table */
    .material-requirements-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -15px;
        padding: 0 15px;
    }
    
    .material-requirements-table table {
        min-width: 650px;
        font-size: 13px;
    }
    
    .material-requirements-table th,
    .material-requirements-table td {
        padding: 8px 10px;
        white-space: nowrap;
    }
    
    .material-requirements-table .material-name {
        max-width: 150px;
        white-space: normal;
        word-wrap: break-word;
    }
}

/* Extra small mobile screens */
@media (max-width: 480px) {
    .hero-content h2 {
        font-size: 1.5rem;
    }
    
    .hero-content p {
        font-size: 0.9rem;
    }
    
    .calculator-section {
        padding: 15px;
    }
    
    .calc-input-group label,
    .calc-result-group label {
        font-size: 0.85rem;
    }
    
    .calc-input-group input {
        padding: 10px;
    }
    
    .paint-card {
        padding: 15px;
    }
    
    .paint-card-header h3 {
        font-size: 1rem;
    }
    
    .variant-badge {
        font-size: 0.7rem;
        padding: 3px 6px;
    }
    
    /* Even smaller material header */
    .material-header-left h4 {
        font-size: 13px;
    }
    
    .material-header-right .btn {
        font-size: 11px;
        padding: 8px 6px;
    }
    
    /* Save lead modal mobile */
    .modal-container {
        width: 95%;
        margin: 10px;
    }
    
    .modal-container .modal-header {
        padding: 15px;
    }
    
    .modal-container .modal-body {
        padding: 15px;
    }
    
    .modal-container .form-input,
    .modal-container .form-textarea {
        padding: 10px 12px;
        font-size: 0.95rem;
    }
    
    .modal-container .modal-footer {
        padding: 15px;
        flex-direction: column;
        gap: 8px;
    }
    
    .modal-container .modal-footer .btn {
        width: 100%;
        justify-content: center;
    }
}

/* Save Lead Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
}

.modal-container {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-container .modal-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 20px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-container .modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.modal-container .modal-body {
    padding: 25px;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-container .form-group {
    margin-bottom: 18px;
}

.modal-container .form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #333;
    font-size: 0.9rem;
}

.modal-container .form-group label .required {
    color: #dc3545;
}

.modal-container .form-input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e1e1e1;
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.2s;
    font-family: inherit;
}

.modal-container .form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
}

.modal-container textarea.form-input {
    resize: vertical;
    min-height: 70px;
}

.lead-calc-summary {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    border-radius: 12px;
    padding: 18px;
    margin-top: 10px;
}

.lead-calc-summary h4 {
    margin: 0 0 15px 0;
    font-size: 0.95rem;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

.lead-calc-summary h4::before {
    content: '📋';
}

.calc-summary-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.calc-summary-row:last-child {
    border-bottom: none;
}

.summary-label {
    color: #666;
    font-size: 0.9rem;
}

.summary-value {
    font-weight: 600;
    color: #333;
}

.summary-value.highlight {
    color: var(--primary-color);
    font-size: 1.1rem;
}

.modal-container .modal-footer {
    padding: 18px 25px;
    background: #f8f9fa;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.modal-container .btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    border: none;
}

.modal-container .btn-secondary {
    background: #e9ecef;
    color: #495057;
}

.modal-container .btn-secondary:hover {
    background: #dee2e6;
}

.modal-container .btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.modal-container .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: white;
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 280px;
    animation: toastSlideIn 0.3s ease;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.toast-success {
    border-left: 4px solid #28a745;
}

.toast.toast-error {
    border-left: 4px solid #dc3545;
}

.toast.toast-info {
    border-left: 4px solid #17a2b8;
}

.toast-icon {
    font-size: 1.2rem;
}

.toast-success .toast-icon { color: #28a745; }
.toast-error .toast-icon { color: #dc3545; }
.toast-info .toast-icon { color: #17a2b8; }

.toast-message {
    flex: 1;
    font-size: 0.95rem;
    color: #333;
}

.toast-close {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0;
}

.toast-close:hover {
    color: #333;
}

/* Print Styles */
@media print {
    .header,
    .hero-search,
    .filter-section,
    .stats-bar,
    .footer,
    .theme-toggle {
        display: none !important;
    }
    
    .formulation-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* ============================================
   V2 LAYOUT STYLES - Two Column Filter + Calc
   ============================================ */

.filter-calc-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.25rem;
}

.filter-column,
.calc-column {
    display: flex;
}

/* V2 Filter Section adjustments */
.filter-calc-row .filter-section {
    margin-bottom: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.filter-calc-row .filter-controls {
    flex-direction: column;
    gap: 0.75rem;
    flex: 1;
}

.filter-calc-row .filter-group {
    min-width: 100%;
}

.filter-calc-row .reset-filters-btn {
    margin-top: auto;
    justify-content: center;
}

/* V2 Calculator Widget */
.calculator-widget {
    background: linear-gradient(135deg, var(--primary-color) 0%, #2d4a6f 100%);
    border-radius: var(--border-radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-lg);
    color: white;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.calculator-widget .calculator-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.calculator-widget .calculator-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: white;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.calculator-widget .calculator-header h3 i {
    color: var(--secondary-color);
}

.calc-variant-badge {
    background: rgba(255,255,255,0.15);
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
}

.calc-variant-badge .variant-label {
    color: rgba(255,255,255,0.7);
    font-style: italic;
}

.calc-variant-badge .variant-name {
    color: white;
    font-weight: 600;
}

/* V2 Calculator Input Row */
.calc-input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.calc-input-row .calc-input-group {
    min-width: 0;
}

/* V2 Big Estimated Cost Display */
.estimated-cost-display {
    background: rgba(0,0,0,0.2);
    border-radius: var(--border-radius);
    padding: 1rem;
    text-align: center;
    margin-bottom: 1rem;
}

.estimated-cost-display .cost-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.7);
    margin-bottom: 0.5rem;
}

.estimated-cost-display .cost-value {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.25rem;
}

.estimated-cost-display .currency {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--secondary-color);
}

.estimated-cost-display .calc-amount {
    font-size: 2.5rem;
    font-weight: 800;
    color: white;
    line-height: 1;
}

/* V2 Pricing Breakdown Grid */
.pricing-breakdown {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-top: auto;
}

.breakdown-item {
    background: rgba(255,255,255,0.1);
    border-radius: var(--border-radius-sm);
    padding: 0.6rem 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.breakdown-item .breakdown-label {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.breakdown-item .breakdown-label i {
    color: var(--secondary-color);
    font-size: 0.65rem;
}

.breakdown-item .breakdown-value {
    font-size: 0.85rem;
    font-weight: 700;
    color: white;
}

/* V2 Responsive */
@media (max-width: 900px) {
    .filter-calc-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .filter-calc-row {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .calc-input-row {
        grid-template-columns: 1fr;
    }
    
    .pricing-breakdown {
        grid-template-columns: 1fr 1fr;
    }
    
    .estimated-cost-display .calc-amount {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    .pricing-breakdown {
        grid-template-columns: 1fr;
    }
}

/* Print Styles */
.print-layout {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: white;
    z-index: 10000;
    overflow: auto;
    padding: 20mm;
    box-sizing: border-box;
    font-family: 'Arial', sans-serif;
    color: #333;
    line-height: 1.4;
}

.print-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #667eea;
}

.print-logos {
    display: flex;
    gap: 20px;
    align-items: center;
}

.print-logo {
    height: 60px;
    max-width: 150px;
    object-fit: contain;
}

.print-title {
    text-align: right;
}

.print-title h1 {
    margin: 0;
    font-size: 24px;
    color: #667eea;
    font-weight: bold;
}

.print-date {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
}

.print-content {
    margin: 20px 0;
}

/* Print Customer Section */
.print-customer-section {
    margin-bottom: 25px;
    padding: 12px 15px;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
}

.print-customer-section h2 {
    font-size: 16px;
    color: #333;
    margin-bottom: 10px;
    border-bottom: 1px solid #ddd;
    padding-bottom: 5px;
}

.customer-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 20px;
}

.customer-info-row {
    display: flex;
    align-items: baseline;
    margin-bottom: 3px;
    font-size: 13px;
    line-height: 1.3;
}

.customer-info-row .info-label {
    font-weight: 600;
    min-width: 100px;
    color: #555;
    flex-shrink: 0;
}

.customer-info-row .info-value {
    flex: 1;
    color: #333;
    word-break: break-word;
}

.print-shade-info {
    margin-bottom: 30px;
}

.print-shade-info h2 {
    font-size: 18px;
    color: #333;
    margin-bottom: 15px;
    border-bottom: 1px solid #ddd;
    padding-bottom: 5px;
}

.shade-info-row {
    display: flex;
    margin-bottom: 8px;
}

.info-label {
    font-weight: bold;
    width: 120px;
    color: #555;
}

.info-value {
    flex: 1;
    color: #333;
}

.print-materials h2 {
    font-size: 18px;
    color: #333;
    margin-bottom: 15px;
    border-bottom: 1px solid #ddd;
    padding-bottom: 5px;
}

.print-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    font-size: 11px;
}

.print-table th,
.print-table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

.print-table th {
    background-color: #f8f9fa;
    font-weight: bold;
    color: #333;
}

.print-table .print-total-row {
    background-color: #e9ecef !important;
    font-weight: bold;
}

.print-total {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #667eea;
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 16px;
    font-weight: bold;
}

.total-label {
    color: #333;
}

.total-amount {
    color: #667eea;
    font-size: 18px;
}

.print-footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
    font-size: 10px;
    color: #666;
    text-align: center;
}

.print-footer p {
    margin: 5px 0;
}

/* Print Media Query */
@media print {
    .print-layout {
        position: static !important;
        width: auto !important;
        height: auto !important;
        padding: 0 !important;
        background: white !important;
        font-size: 11pt !important;
        line-height: 1.3 !important;
    }
    
    .print-header {
        margin-bottom: 12pt;
        padding-bottom: 8pt;
    }
    
    .print-title h1 {
        font-size: 16pt;
    }
    
    .print-customer-section {
        margin-bottom: 12pt;
        padding: 8pt 10pt;
    }
    
    .print-customer-section h2 {
        font-size: 12pt;
        margin-bottom: 6pt;
    }
    
    .customer-info-grid {
        gap: 3pt 15pt;
    }
    
    .customer-info-row {
        font-size: 10pt;
    }
    
    .customer-info-row .info-label {
        min-width: 80pt;
    }
    
    .print-shade-info h2,
    .print-materials h2 {
        font-size: 12pt;
        margin-bottom: 6pt;
    }
    
    .print-table {
        font-size: 9pt;
    }
    
    .total-row {
        font-size: 11pt;
    }
    
    .total-amount {
        font-size: 13pt;
    }
    
    .print-footer {
        font-size: 8pt;
        margin-top: 15pt;
    }
    
    /* Hide non-print elements during print */
    body > *:not(.print-layout) {
        display: none !important;
    }
}
