/* * --- Beauty CSS ---
 * This file contains styles for a modern EMI calculator web application.
        /* * --- Modern Color Palette & Base Styles ---
         * Defines a set of CSS variables for consistent theming and
         * applies basic styles to the body and universal box-sizing.
         */
:root {
    --bg-dark: #111827;
    /* Dark Slate Gray */
    --bg-light: #1f2937;
    /* Lighter Slate */
    --primary-accent: #22d3ee;
    /* Vibrant Cyan */
    --primary-accent-dark: #06b6d4;
    --text-primary: #f9fafb;
    /* Off-white */
    --text-secondary: #9ca3af;
    /* Medium Gray */
    --border-color: #374151;
    --error-red: #f87171;
    --error-bg: #450a0a;
}

/* Universal box-sizing for consistent layout */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Body styles: sets font, background gradient, text color, and centers content */
body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(45deg, #111827, #0c1a2e);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}

/* * --- Animations ---
         * Keyframe animations for smooth transitions of elements.
         */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

/* * --- Calculator Container ---
         * Styles for the main calculator wrapper, including sizing, background,
         * border, shadow, padding, and initial animation.
         */
.calculator-container {
    width: 100%;
    max-width: 480px;
    background-color: var(--bg-light);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    padding: 2rem;
    animation: fadeIn 0.6s ease-out;
}

/* * --- Header ---
         * Styles for the title and subtitle of the calculator.
         */
.header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.header h1 {
    font-size: 1.875rem;
    /* 30px */
    font-weight: 700;
    color: var(--primary-accent);
    display: flex;
    /* Enable flexbox for icon alignment */
    align-items: center;
    /* Vertically center icon and text */
    justify-content: center;
    /* Horizontally center content */
    gap: 0.75rem;
    /* Space between icon and text */
}

.header h1 i {
    font-size: 1.5rem;
    /* Icon size */
    color: var(--primary-accent);
}

/* * --- Form Elements ---
         * Styles for input fields and their labels within the EMI form.
         */
.emi-form .form-group {
    margin-bottom: 1.5rem;
    position: relative;
    /* For icon positioning */
}

.emi-form label {
    display: block;
    font-size: 0.875rem;
    /* 14px */
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: 0.875rem 1rem;
    padding-left: 2.75rem;
    /* Space for icon */
    border: 1px solid var(--border-color);
    background-color: var(--bg-dark);
    color: var(--text-primary);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.form-input::placeholder {
    color: #4b5563;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-accent);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.2);
}

/* --- Input Icon Positioning ---
         * Positions the icon absolutely within its form-group.
         * The 'top' value is calculated to align the icon's vertical center
         * with the vertical center of the input field.
         * Calculation:
         * - Label height (approx 1rem for font-size 0.875rem + line-height)
         * - Label margin-bottom (0.5rem)
         * - Input padding-top (0.875rem)
         * - Half of input's font-size (1rem / 2 = 0.5rem)
         * Total top from form-group: 1rem (label) + 0.5rem (label margin) + 0.875rem (input padding-top) + 0.5rem (half input font-size) = 2.875rem
         * translateY(-50%) then moves the icon up by half its own height to truly center it.
         */
.input-icon {
    position: absolute;
    left: 1rem;
    top: 2.875rem;
    /* Precise vertical positioning relative to form-group */
    transform: translateY(-50%);
    /* Centers the icon vertically */
    color: var(--text-secondary);
    pointer-events: none;
    /* Make icon non-interactive so input clicks through */
    font-size: 1rem;
}

/* --- Button --- */
.calculate-btn {
    width: 100%;
    background-color: var(--primary-accent);
    color: var(--bg-dark);
    font-weight: 700;
    padding: 1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.125rem;
    transition: background-color 0.3s, transform 0.2s;
    display: flex;
    /* Enable flexbox for button content */
    align-items: center;
    /* Vertically center icon and text */
    justify-content: center;
    /* Horizontally center content */
    gap: 0.75rem;
    /* Space between icon and text */
}

.calculate-btn:hover {
    background-color: var(--primary-accent-dark);
    transform: translateY(-2px);
}

/* * --- Results Section ---
         * Styles for displaying the calculated EMI, total interest, and total payment.
         * Initially hidden and revealed by JavaScript.
         */
.results-section {
    margin-top: 2.5rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    display: none;
    /* Hidden by default, JS will show it */
    animation: slideUp 0.5s ease-out;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    background-color: var(--bg-dark);
}

.result-item.highlight {
    background-color: rgba(34, 211, 238, 0.1);
    border: 1px solid var(--primary-accent);
}

.result-item .label {
    color: var(--text-secondary);
    display: flex;
    /* Align icon and text */
    align-items: center;
    gap: 0.5rem;
    /* Space between icon and label text */
}

.result-item .value {
    font-weight: 600;
    font-size: 1.125rem;
}

.result-item.highlight .value {
    color: var(--primary-accent);
    font-size: 1.75rem;
    font-weight: 700;
}

/* * --- Error Box ---
         * Styles for displaying validation error messages.
         * Initially hidden and revealed by JavaScript.
         */
.error-box {
    margin-top: 1rem;
    padding: 0.75rem;
    background-color: var(--error-bg);
    border: 1px solid var(--error-red);
    color: var(--error-red);
    border-radius: 8px;
    text-align: center;
    display: none;
    /* Hidden by default */
    animation: slideUp 0.3s ease-out;
}

/* * --- Responsive Design ---
         * Adjustments for smaller screens to ensure readability and usability.
         */
@media (max-width: 480px) {
    .calculator-container {
        padding: 1.5rem;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .result-item.highlight .value {
        font-size: 1.5rem;
    }
}