:root {
    --sidebar-width: 260px;
    --budget-panel-width: 500px; 
    /* Modern Color Palette */
    --primary-color: #3b82f6; /* A slightly softer blue than #2563eb */
    --primary-dark: #2563eb;
    --secondary-color: #1e293b;
    --accent-color: #f59e0b;
    --bg-color: #f1f5f9;
    --surface-color: #ffffff;
    --border-color: #e2e8f0;
    --text-muted: #64748b;
    --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] {
    --primary-color: #60a5fa; 
    --primary-dark: #3b82f6;
    --secondary-color: #f8fafc; /* Whiter text */
    --bg-color: #020617; /* Darker black/slate for high contrast */
    --surface-color: #1e293b; 
    --border-color: #475569; /* Lighter border for visibility */
    --text-muted: #cbd5e1; /* Much lighter gray for readability */
    --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.6);
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: var(--secondary-color);
    transition: background-color 0.3s, color 0.3s;
}

/* Header */
.header-banner {
    background: var(--surface-color); /* Removed glass effect for consistency or use rgba with var */
    border-bottom: 1px solid var(--border-color);
    padding: 15px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05); /* Could try to use var but low priority */
    z-index: 100;
}

.header-banner h1 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--secondary-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

.config-badge {
    background: #e2e8f0;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #475569;
    border: 1px solid #cbd5e1;
}

/* Layout Principal */
.main-wrapper {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar Categorías */
.sidebar {
    width: var(--sidebar-width);
    background: var(--surface-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px;
    gap: 8px;
    overflow-y: auto;
}

.category-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #94a3b8;
    font-weight: 800;
    margin-bottom: 12px;
    letter-spacing: 0.05em;
}

.nav-btn {
    text-align: left;
    padding: 12px 16px;
    border-radius: 12px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.95rem;
}

.nav-btn:hover {
    background: #f8fafc;
    color: var(--primary-color);
    transform: translateX(2px);
}

.nav-btn.active {
    background: #eff6ff; /* Washed blue */
    color: var(--primary-color);
    font-weight: 600;
}

/* Área Central */
.content-area {
    flex: 1;
    padding: 0;
    overflow-y: auto;
    background: var(--bg-color);
    display: flex;
    flex-direction: column;
}

.items-container {
    padding: 40px 60px; /* More horizontal padding */
    max-width: 1400px; /* Increased max-width */
    margin: 0 auto;
    width: 100%;
}

.section-header {
    margin-bottom: 24px;
    padding: 12px 16px;
    background: var(--surface-color); /* Changed to var */
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
    color: var(--secondary-color);
    text-transform: capitalize;
    font-weight: 700;
    letter-spacing: -0.02em;
    border-bottom: none; /* Removed border since we have shadow/bg now */
}

/* Tarjetas de Productos */
.product-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 20px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
    box-shadow: var(--shadow-soft);
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    border-color: #cbd5e1;
}

.product-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.product-title {
    font-weight: 700;
    color: var(--secondary-color);
    font-size: 1.25rem;
    margin-bottom: 6px;
    line-height: 1.3;
}

.product-dims {
    font-size: 0.85rem;
    color: var(--text-muted);
    background: #f1f5f9;
    padding: 4px 10px;
    border-radius: 6px;
    display: inline-block;
    font-weight: 500;
}

.product-controls {
    display: flex;
    flex-wrap: wrap; 
    gap: 15px;
    align-items: center;
    justify-content: space-between;
    background: #f8fafc;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .product-controls {
    background: #0f172a; 
    border-color: #334155;
}

[data-theme="dark"] .form-select-sm {
    background-color: #1e293b;
    color: var(--secondary-color);
    border-color: #475569;
}

[data-theme="dark"] .product-dims {
    background: #334155; /* Darker background for pill */
    color: #e2e8f0;
}

[data-theme="dark"] .budget-item {
    background: #0f172a;
    border-color: #334155;
}

[data-theme="dark"] .budget-footer {
    background: #0f172a;
    border-color: #334155;
}

[data-theme="dark"] .input-group-text {
    background: #334155;
    color: #e2e8f0;
    border-color: #475569;
}

[data-theme="dark"] #discount-input {
    background: #1e293b;
    color: white;
    border-color: #475569;
}

[data-theme="dark"] .budget-header {
    background: #0f172a;
    border-bottom: 1px solid #334155;
    color: white;
}

.material-select-group {
    flex: 1 1 100%;
    min-width: 200px;
}

.material-select-group label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 6px;
    display: block;
    letter-spacing: 0.03em;
}

.form-select-sm {
    border-color: #cbd5e1;
    font-size: 0.95rem;
    padding-top: 6px;
    padding-bottom: 6px;
    border-radius: 8px;
    width: 100%;
}

.form-select-sm:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.price-tag {
    text-align: right;
    margin-left: auto; /* Push to right if wrapped alone, or stays right */
}

.price-label {
    font-size: 0.7rem;
    color: #94a3b8;
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 2px;
}

.price-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--secondary-color);
    line-height: 1;
}

.btn-add {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 38px;  /* Reduced from 48px */
    height: 38px; /* Reduced from 48px */
    border-radius: 10px; /* Adjusted radius */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.3);
    margin-left: 15px;
}

.btn-add svg {
    width: 20px;
    height: 20px;
}

.btn-add:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
    box-shadow: 0 6px 8px -1px rgba(59, 130, 246, 0.4);
}

.btn-add:active {
    transform: scale(0.95);
}

/* Panel de Presupuesto */
#resizer {
    width: 6px;
    background: transparent;
    cursor: col-resize;
    transition: background 0.2s;
    z-index: 50;
    margin-right: -3px; /* visual overlap */
    position: relative;
    flex-shrink: 0; 
}

#resizer:hover, #resizer.resizing {
    background: var(--primary-color);
}

.budget-panel {
    width: var(--budget-panel-width);
    min-width: 300px; /* Minimum width constraint */
    max-width: 800px; /* Maximum width constraint */
    background: var(--surface-color);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 20;
    box-shadow: -4px 0 25px rgba(0,0,0,0.05);
}

.budget-header {
    padding: 24px;
    background: var(--secondary-color);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.budget-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.budget-item {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    position: relative;
    transition: border-color 0.2s;
}

.budget-item:hover {
    border-color: #cbd5e1;
}

.budget-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.budget-item-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--secondary-color);
    padding-right: 30px;
    line-height: 1.4;
}

.item-quantity-badge {
    background: var(--primary-color);
    color: white;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 6px;
    margin-right: 8px;
    font-weight: 700;
    vertical-align: middle;
}

.budget-item-detail {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 6px;
}

.budget-item-price {
    font-weight: 700;
    color: var(--primary-color);
    text-align: right;
    margin-top: 10px;
    font-size: 1.1rem;
}

.budget-unit-price {
    font-size: 0.75rem;
    color: #94a3b8;
    font-weight: 400;
}

.btn-remove {
    position: absolute;
    top: 12px;
    right: 12px;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    border: none;
    padding: 4px;
    border-radius: 6px;
    cursor: pointer;
    opacity: 0.7;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-remove:hover { 
    opacity: 1; 
    background: rgba(239, 68, 68, 0.2);
}

.budget-footer {
    padding: 24px;
    border-top: 1px solid var(--border-color);
    background: #f8fafc;
}

.subtotal-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 24px;
    padding-top: 12px;
    border-top: 1px dashed var(--border-color);
}

.total-amount {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--secondary-color);
    line-height: 1;
    letter-spacing: -0.03em;
}

/* Responsive */
@media (max-width: 1024px) {
    .main-wrapper { flex-direction: column; overflow-y: auto; }
    .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border-color); max-height: 150px; flex-direction: row; flex-wrap: wrap; }
    .nav-btn { width: auto; }
    .budget-panel { width: 100%; border-left: none; border-top: 1px solid var(--border-color); height: auto; max-height: 50vh; }
}
