@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&display=swap');

:root {
    --primary-gradient: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    --bg-color: #0f172a;
    --text-color: #f8fafc;
    --card-bg: rgba(255, 255, 255, 0.05);
    --border-color: rgba(255, 255, 255, 0.1);
    --glass-blur: 15px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 60px 20px;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
}

body::-webkit-scrollbar {
    width: 8px;
}

body::-webkit-scrollbar-track {
    background: #0f172a;
}

body::-webkit-scrollbar-thumb {
    background: #1e293b;
    border-radius: 10px;
}

body::-webkit-scrollbar-thumb:hover {
    background: #334155;
}

/* Background Blobs */
.bg-blobs {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: -1;
}

.blob {
    position: absolute;
    width: 500px;
    height: 500px;
    background: var(--primary-gradient);
    filter: blur(80px);
    /* Reduced blur */
    border-radius: 50%;
    opacity: 0.12;
    will-change: transform;
}

.blob-2 {
    right: -10%;
    bottom: -10%;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

/* Calculator Card */
.calculator-card {
    background: var(--card-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 30px 40px;
    width: 95%;
    max-width: 550px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    animation: scaleIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

header {
    text-align: center;
    margin-bottom: 30px;
    position: relative;
}

.header-top {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 10px;
}

.currency-switcher {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 4px 8px;
}

.currency-switcher select {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 0.85rem;
    font-weight: 600;
    outline: none;
    cursor: pointer;
}

header h1 {
    font-size: 2.2rem;
    font-weight: 800;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

header p {
    opacity: 0.6;
    margin-top: 5px;
}

/* Input Styles */
.input-group {
    margin-bottom: 25px;
    display: flex;
    flex-direction: column;
}

label {
    font-size: 0.95rem;
    font-weight: 600;
    color: #94a3b8;
    margin-bottom: 10px;
}

input[type="number"] {
    width: 100%;
    padding: 12px 15px;
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    outline: none;
    transition: all 0.3s;
}

input[type="number"]:focus {
    border-color: #43e97b;
    background: rgba(255, 255, 255, 0.08);
}

.input-with-currency {
    position: relative;
    display: flex;
    align-items: center;
}

.currency-symbol {
    position: absolute;
    left: 15px;
    color: #43e97b;
    font-weight: 800;
}

.input-with-currency input {
    padding-left: 35px;
}

.tenure-inputs {
    display: flex;
    gap: 10px;
}

.tenure-inputs .split-input {
    flex: 1;
    position: relative;
}

.tenure-inputs .split-input input {
    padding-right: 50px !important;
    text-align: center;
}

.tenure-inputs .input-unit {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    color: #64748b;
    pointer-events: none;
}

.input-row {
    display: flex;
    flex-direction: column;
    /* Stack for more space on mobile */
    gap: 5px;
}

/* Slider Style */
.slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    outline: none;
    margin-top: 15px;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: #43e97b;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(67, 233, 123, 0.5);
    transition: all 0.2s;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* Button Group */
.button-group {
    display: flex;
    gap: 15px;
    margin-top: 10px;
}

.calculate-btn {
    flex: 2;
    padding: 16px;
    border-radius: 12px;
    border: none;
    background: #26e6a0;
    color: #0f172a;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 10px 20px rgba(38, 230, 160, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.calculate-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.clear-btn {
    flex: 1;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.05);
    color: #cbd5e1;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

/* Result Section */
.result-section {
    margin-top: 40px;
    display: none;
    animation: fadeIn 0.8s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

.result-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 20px;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.result-item .label {
    font-size: 0.85rem;
    color: #94a3b8;
    font-weight: 600;
}

.result-item .value {
    font-size: 1.5rem;
    font-weight: 800;
    color: white;
}

.result-item.highlight {
    grid-column: span 2;
    background: rgba(67, 233, 123, 0.1);
    border-color: rgba(67, 233, 123, 0.2);
}

.result-item.highlight .value {
    color: #43e97b;
    font-size: 1.8rem;
}

/* Pie Chart Visualization */
.chart-container {
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 20px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 16px;
}

.pie-chart {
    position: relative;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: conic-gradient(#43e97b 0% var(--p-percent, 70%), #fbbf24 var(--p-percent, 70%) 100%);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
}

.chart-center {
    position: absolute;
    width: 60px;
    height: 60px;
    background: #1e293b;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.chart-legend {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    font-weight: 600;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.p-dot {
    background: #43e97b;
}

.i-dot {
    background: #fbbf24;
}

@media (max-width: 480px) {
    .calculator-card {
        padding: 30px 20px;
    }

    .input-row {
        flex-direction: column;
        gap: 0;
    }

    .result-grid {
        grid-template-columns: 1fr;
    }

    .result-item.highlight {
        grid-column: span 1;
    }

    .chart-container {
        flex-direction: column;
        gap: 20px;
    }
}