:root {
    --primary: #8B5CF6;
    --primary-light: #A78BFA;
    --primary-dark: #6D28D9;
    --secondary: #10B981;
    --bg-dark: #0F172A;
    --bg-card: rgba(30, 41, 59, 0.7);
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    --accent-glow: rgba(139, 92, 246, 0.5);
    --font-family: 'Outfit', 'Inter', system-ui, -apple-system, sans-serif;
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.8);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-dark);
    background-image:
        radial-gradient(circle at 0% 0%, rgba(139, 92, 246, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 100% 100%, rgba(16, 185, 129, 0.1) 0%, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    font-family: var(--font-family);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1rem;
    width: 100%;
}

.calculator-header {
    text-align: center;
    margin-bottom: 3rem;
}

.calculator-header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #FFF 0%, #A78BFA 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}

.header-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

.btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    padding: 0.6rem 1.2rem;
    cursor: pointer;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

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

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

.btn-outline-primary {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary-light);
}

.btn-outline-primary:hover {
    background: rgba(139, 92, 246, 0.1);
}

.btn-outline-secondary {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
}

.btn-outline-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.calculator-grid {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 2rem;
    align-items: start;
}

.calculator-container {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 32px;
    padding: 2.5rem;
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}

.form-section {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--glass-border);
}

.form-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.section-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
}

.section-header i {
    color: var(--primary-light);
}

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

label {
    display: block;
    margin-bottom: 0.6rem;
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

input,
select {
    width: 100%;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    color: var(--text-main);
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(15, 23, 42, 0.8);
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.15);
}

.input-group {
    display: flex;
    align-items: stretch;
}

.input-group input {
    border-radius: 16px 0 0 16px;
}

.input-group-text {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-left: none;
    padding: 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-radius: 0 16px 16px 0;
    min-width: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.material-row {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    position: relative;
}

.material-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.material-header h4 {
    color: var(--text-main);
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.remove-material {
    background: transparent;
    border: none;
    color: #ef4444;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.remove-material:hover {
    background: rgba(239, 68, 68, 0.1);
}

.color-preview {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: inline-block;
    border: 2px solid var(--glass-border);
    cursor: pointer;
    transition: transform 0.2s ease;
}

.color-preview:hover {
    transform: scale(1.1);
}

.results-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 32px;
    padding: 2.5rem;
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    position: sticky;
    top: 2rem;
}

.results-card h3 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 2rem;
    color: var(--text-main);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--glass-border);
}

.result-item:last-child {
    border-bottom: none;
}

.result-item span:first-child {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.result-item span:last-child {
    color: var(--text-main);
    font-weight: 600;
    font-size: 1rem;
}

.pricing-tiers {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--glass-border);
}

.pricing-tiers h6 {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1.5rem;
    text-align: center;
}

.pricing-option {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.pricing-option:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--primary);
}

.pricing-option input[type="radio"] {
    width: auto;
    margin-right: 0.75rem;
    cursor: pointer;
}

.pricing-option label {
    margin: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    text-transform: none;
}

.badge {
    padding: 0.35rem 0.75rem;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

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

.bg-success {
    background: var(--secondary);
    color: white;
}

.bg-warning {
    background: #f59e0b;
    color: white;
}

.bg-danger {
    background: #ef4444;
    color: white;
}

.bg-secondary {
    background: #6b7280;
    color: white;
}

.pricing-option .fw-bold {
    font-weight: 700;
    color: var(--primary-light);
}

.total-cost-display {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid var(--primary);
    text-align: center;
}

.total-cost-display span:first-child {
    display: block;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.total-cost-display span:last-child {
    display: block;
    font-size: 2rem;
    font-weight: 900;
    color: var(--primary-light);
    text-shadow: 0 0 20px rgba(139, 92, 246, 0.3);
}

.chart-container {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--glass-border);
}

.chart-container h6 {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1.5rem;
    text-align: center;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--glass-border);
}

.form-actions .btn {
    flex: 1;
}

.form-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    font-style: italic;
}

/* Color Picker Popup */
.color-picker-popup {
    position: absolute;
    z-index: 1000;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: none;
}

.color-palette {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 8px;
    margin-bottom: 1rem;
}

.color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid var(--glass-border);
    transition: transform 0.2s ease;
}

.color-swatch:hover {
    transform: scale(1.15);
    border-color: var(--primary);
}

.color-input {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.color-input input[type="color"] {
    width: 40px;
    height: 40px;
    padding: 0;
    border: 2px solid var(--glass-border);
    border-radius: 8px;
    cursor: pointer;
}

.color-input input[type="text"] {
    flex: 1;
    padding: 0.5rem;
    font-size: 0.85rem;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .calculator-grid {
        grid-template-columns: 1fr;
    }

    .results-card {
        position: static;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .calculator-container,
    .results-card {
        padding: 1.5rem;
    }

    .calculator-header h1 {
        font-size: 2rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .header-controls {
        flex-direction: column;
        width: 100%;
    }

    .header-controls .btn {
        width: 100%;
    }
}