/* ===== CSS Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Color Palette */
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --accent-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --success-color: #10b981;
    --error-color: #ef4444;
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);

    /* Neutral Colors */
    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    /* Spacing */
    --space-xs: 0.5rem;
    --space-sm: 0.75rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 2rem;

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-card: 0 0 40px rgba(0, 0, 0, 0.1);
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: 1.6;
    color: var(--gray-800);
    background: var(--bg-gradient);
    min-height: 100vh;
    padding: var(--space-lg);
    background-attachment: fixed;
}

/* ===== Container ===== */
.container {
    max-width: 800px;
    margin: 0 auto;
}

/* ===== Header ===== */
.header {
    text-align: center;
    margin-bottom: var(--space-2xl);
    color: var(--white);
}

.header h1 {
    font-size: var(--font-size-3xl);
    font-weight: 700;
    margin-bottom: var(--space-sm);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: var(--font-size-lg);
    opacity: 0.95;
    font-weight: 400;
}

/* ===== Calculator Card ===== */
.calculator-card {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: var(--space-2xl);
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(10px);
}

/* ===== Form Styles ===== */
.calculator-form {
    display: grid;
    gap: var(--space-xl);
    margin-bottom: var(--space-2xl);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.form-group label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.label-text {
    font-weight: 600;
    font-size: var(--font-size-base);
    color: var(--gray-800);
}

.label-hint {
    font-size: var(--font-size-sm);
    color: var(--gray-500);
    font-weight: 400;
}

/* ===== Tooltip Styles ===== */
.has-tooltip {
    position: relative;
    cursor: help;
}

.has-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 0;
    top: calc(100% + 8px);
    background: var(--gray-900);
    color: var(--white);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    line-height: 1.5;
    width: max-content;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-5px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
    white-space: normal;
}

.has-tooltip:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Tooltip arrow */
.has-tooltip::before {
    content: '';
    position: absolute;
    left: 12px;
    top: calc(100% + 2px);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid var(--gray-900);
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.has-tooltip:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Responsive tooltip sizing */
@media (max-width: 639px) {
    .has-tooltip::after {
        max-width: calc(100vw - 3rem);
        left: 50%;
        transform: translateX(-50%) translateY(-5px);
    }

    .has-tooltip:hover::after {
        transform: translateX(-50%) translateY(0);
    }

    .has-tooltip::before {
        left: 50%;
        transform: translateX(-50%);
    }
}

/* ===== Input Styles ===== */
.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper input[type="number"] {
    flex: 1;
    padding: 0.75rem 1rem;
    padding-right: 3rem;
    font-size: var(--font-size-base);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    background: var(--white);
    transition: all 0.2s ease;
    font-family: var(--font-family);
}

.input-wrapper input[type="number"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.input-suffix {
    position: absolute;
    right: 1rem;
    color: var(--gray-500);
    font-weight: 500;
    pointer-events: none;
}

/* Remove spinner arrows from number inputs */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* ===== Toggle Buttons ===== */
.toggle-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm);
}

.toggle-btn {
    padding: 0.75rem 1.5rem;
    font-size: var(--font-size-base);
    font-weight: 500;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    background: var(--white);
    color: var(--gray-700);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-family);
}

.toggle-btn:hover {
    border-color: var(--gray-300);
    background: var(--gray-50);
}

.toggle-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--white);
    border-color: transparent;
}

/* ===== Slider Styles ===== */
.slider-wrapper {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--gray-200);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

input[type="range"]::-moz-range-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease;
}

input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.2);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: var(--font-size-sm);
    color: var(--gray-500);
}

.slider-value {
    font-weight: 600;
    color: #667eea;
}

/* ===== Results Section ===== */
.results {
    border-top: 2px solid var(--gray-100);
    padding-top: var(--space-xl);
}

.results-title {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: var(--space-lg);
    text-align: center;
}

.results-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-md);
}

.result-card {
    background: var(--gray-50);
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    text-align: center;
    border: 2px solid var(--gray-100);
    transition: all 0.3s ease;
}

.result-card:hover {
    border-color: var(--gray-200);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.result-card.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: var(--white);
}

.result-label {
    font-size: var(--font-size-sm);
    font-weight: 500;
    margin-bottom: var(--space-xs);
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.result-card.primary .result-label {
    opacity: 0.95;
}

.result-value {
    font-size: var(--font-size-3xl);
    font-weight: 700;
}

.result-card.primary .result-value {
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.error-message {
    margin-top: var(--space-md);
    padding: var(--space-md);
    background: #fef2f2;
    color: var(--error-color);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    display: none;
}

.error-message.show {
    display: block;
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    margin-top: var(--space-2xl);
    color: var(--white);
    font-size: var(--font-size-sm);
    opacity: 0.9;
}

/* ===== Responsive Design ===== */
@media (min-width: 640px) {
    .results-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .result-card.primary {
        grid-column: 1 / -1;
    }
}

@media (max-width: 639px) {
    body {
        padding: var(--space-md);
    }

    .calculator-card {
        padding: var(--space-lg);
    }

    .header h1 {
        font-size: var(--font-size-2xl);
    }

    .subtitle {
        font-size: var(--font-size-base);
    }
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-card {
    animation: fadeIn 0.3s ease;
}