/* ==========================================
   RESET & BASE STYLES
   ========================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ==========================================
   CSS VARIABLES - DESIGN SYSTEM
   ========================================== */

:root {
    /* FECCOO Brand Colors */
    --color-primary: #e30613;
    /* FECCOO Red */
    --color-primary-dark: #b30510;
    /* Darker Red */
    --color-primary-light: #ff1a28;
    /* Lighter Red */
    --color-secondary: #000000;
    /* Black */
    --color-accent: #e30613;
    /* Red accent */
    --color-success: #e30613;
    /* Red for consistency */
    --color-warning: #e30613;

    /* Backgrounds */
    --color-bg-primary: #ffffff;
    /* White background */
    --color-bg-secondary: #f5f5f5;
    /* Light gray */
    --color-bg-card: rgba(255, 255, 255, 0.95);
    --color-bg-input: #ffffff;

    /* Text */
    --color-text-primary: #000000;
    /* Black text */
    --color-text-secondary: #333333;
    /* Dark gray */
    --color-text-muted: #666666;
    /* Medium gray */

    /* Gradients - Using FECCOO red */
    --gradient-primary: linear-gradient(135deg, #e30613 0%, #b30510 100%);
    --gradient-secondary: linear-gradient(135deg, #ff1a28 0%, #e30613 100%);
    --gradient-accent: linear-gradient(135deg, #e30613 0%, #b30510 100%);
    --gradient-bg: linear-gradient(135deg, #ffffff 0%, #f5f5f5 50%, #ffffff 100%);

    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;

    /* Border Radius */
    --radius-sm: 0.5rem;
    --radius-md: 1rem;
    --radius-lg: 1.5rem;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.2);
    --shadow-glow: 0 0 20px rgba(227, 6, 19, 0.3);

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-size-xs: 0.75rem;
    --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;
    --font-size-4xl: 2.5rem;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 350ms ease;
}

/* ==========================================
   ACCESSIBILITY - SKIP LINK
   ========================================== */

.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--color-primary);
    color: white;
    padding: var(--spacing-sm) var(--spacing-md);
    text-decoration: none;
    font-weight: 600;
    z-index: 100;
    border-radius: 0 0 var(--radius-sm) 0;
}

.skip-link:focus {
    top: 0;
    outline: 3px solid var(--color-secondary);
    outline-offset: 2px;
}

/* ==========================================
   BODY & CONTAINER
   ========================================== */

body {
    font-family: var(--font-family);
    background: var(--gradient-bg);
    background-attachment: fixed;
    color: var(--color-text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--spacing-lg);
}

/* ==========================================
   HEADER
   ========================================== */

.header {
    position: relative;
    text-align: center;
    margin-bottom: var(--spacing-xl);
    animation: fadeInDown 0.6s ease;
}

.header-logo-link {
    display: inline-block;
    text-decoration: none;
}

.header-logo {
    max-width: 200px;
    height: auto;
    margin: 0 auto var(--spacing-md);
    display: block;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
    transition: transform var(--transition-base);
}

.header-logo:hover {
    transform: scale(1.05);
}

.title {
    font-size: var(--font-size-4xl);
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--spacing-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
}

.title-icon {
    font-size: var(--font-size-4xl);
    filter: drop-shadow(0 4px 8px rgba(99, 102, 241, 0.4));
}

.subtitle {
    font-size: var(--font-size-lg);
    color: var(--color-text-secondary);
    font-weight: 500;
}

/* ==========================================
   ACCESSIBILITY - FOCUS INDICATORS
   ========================================== */

/* Enhanced focus indicators for keyboard navigation */
*:focus {
    outline: 3px solid var(--color-primary);
    outline-offset: 2px;
}

/* Remove default focus for mouse users, keep for keyboard */
*:focus:not(:focus-visible) {
    outline: none;
}

*:focus-visible {
    outline: 3px solid var(--color-primary);
    outline-offset: 2px;
}

/* ==========================================
   MAIN CONTENT
   ========================================== */

.main {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

/* ==========================================
   CARDS
   ========================================== */

.calculator-card,
.results-section {
    background: var(--color-bg-card);
    border: 2px solid var(--color-secondary);
    border-radius: var(--radius-md);
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-md);
    animation: fadeInUp 0.6s ease;
}

.card-title {
    font-size: var(--font-size-2xl);
    font-weight: 600;
    margin-bottom: var(--spacing-lg);
    color: var(--color-text-primary);
}

/* ==========================================
   FORM STYLES
   ========================================== */

.form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
}

.form-label {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text-secondary);
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.label-detail {
    display: block;
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
    font-weight: 400;
    margin-top: 2px;
    line-height: 1.3;
}

.form-help {
    display: block;
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
    margin-top: var(--spacing-xs);
}

.label-icon {
    font-size: var(--font-size-lg);
    display: inline-flex;
    align-items: center;
    margin-right: 0.5rem;
}

.form-select,
.form-input {
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--color-bg-input);
    border: 2px solid #cccccc;
    border-radius: var(--radius-sm);
    color: var(--color-text-primary);
    font-size: var(--font-size-base);
    font-family: var(--font-family);
    transition: all var(--transition-base);
    outline: none;
}

.form-select:hover,
.form-input:hover {
    border-color: var(--color-primary);
}

.form-select:focus,
.form-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(227, 6, 19, 0.1);
}

.form-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Ensure adequate touch target size for mobile (44x44px minimum) */
@media (pointer: coarse) {

    .form-select,
    .form-input {
        min-height: 44px;
        padding: var(--spacing-md);
    }
}

.form-select option {
    background: var(--color-bg-secondary);
    color: var(--color-text-primary);
}

/* ==========================================
   BUTTON
   ========================================== */

.btn-calculate {
    margin-top: var(--spacing-md);
    padding: var(--spacing-md) var(--spacing-xl);
    background: var(--gradient-primary);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: var(--font-size-lg);
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
}

.btn-calculate:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.btn-calculate:active {
    transform: translateY(0);
}

.btn-icon {
    font-size: var(--font-size-xl);
}

/* Ensure button meets minimum touch target size */
@media (pointer: coarse) {
    .btn-calculate {
        min-height: 44px;
        padding: var(--spacing-md) var(--spacing-xl);
    }
}

/* ==========================================
   RESULTS SECTION
   ========================================== */

.results-section {
    animation: fadeInUp 0.6s ease 0.2s backwards;
}

.results-section.hidden {
    display: none;
}

.salary-breakdown {
    background: var(--color-bg-input);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    border-left: 4px solid var(--color-primary);
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-xs) 0;
    font-size: var(--font-size-sm);
}

.breakdown-item:not(:last-child) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.breakdown-label {
    color: var(--color-text-secondary);
}

.breakdown-value {
    color: var(--color-text-primary);
    font-weight: 600;
}

.breakdown-total {
    margin-top: var(--spacing-sm);
    padding-top: var(--spacing-sm);
    border-top: 2px solid rgba(99, 102, 241, 0.3);
    font-size: var(--font-size-base);
    font-weight: 700;
}

.breakdown-total .breakdown-label {
    color: var(--color-primary-light);
}

.breakdown-total .breakdown-value {
    color: var(--color-primary-light);
    font-size: var(--font-size-lg);
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.result-card {
    background: var(--color-bg-card);
    border: 2px solid #e0e0e0;
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    text-align: center;
    transition: all var(--transition-base);
    animation: scaleIn 0.4s ease backwards;
}

.result-card:nth-child(1) {
    animation-delay: 0.1s;
}

.result-card:nth-child(2) {
    animation-delay: 0.2s;
}

.result-card:nth-child(3) {
    animation-delay: 0.3s;
}

.result-card:nth-child(4) {
    animation-delay: 0.4s;
}

.result-card:hover {
    transform: translateY(-4px);
    border-color: var(--color-primary);
    box-shadow: var(--shadow-md);
}

.result-card.highlight {
    background: rgba(227, 6, 19, 0.05);
    border-color: var(--color-primary);
    border-width: 3px;
}

.result-year {
    font-size: calc(var(--font-size-xl) * 1.15);
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: var(--spacing-xs);
}

.result-amount {
    font-size: var(--font-size-3xl);
    font-weight: 700;
    color: var(--color-text-primary);
    margin-bottom: var(--spacing-xs);
}

.result-label {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--spacing-xs);
}

.result-increase {
    font-size: var(--font-size-xs);
    color: white;
    font-weight: 600;
    background: var(--color-primary);
    padding: var(--spacing-xs);
    border-radius: var(--radius-sm);
}

.result-diff {
    font-size: var(--font-size-sm);
    color: var(--color-primary);
    font-weight: 700;
    margin-top: var(--spacing-xs);
    padding: var(--spacing-xs);
    background: rgba(227, 6, 19, 0.1);
    border-radius: var(--radius-sm);
}

.result-subtitle {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--spacing-xs);
    font-weight: 500;
}

.result-card.total-increase {
    background: var(--gradient-primary);
    border-color: var(--color-primary-dark);
    border-width: 3px;
    animation-delay: 0.5s;
}

.result-card.total-increase .result-year {
    color: white;
    font-size: var(--font-size-2xl);
}

.result-card.total-increase .result-subtitle {
    color: rgba(255, 255, 255, 0.9);
}

.result-card.total-increase .result-amount {
    color: white;
    font-size: var(--font-size-4xl);
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.result-card.total-increase .result-increase {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: var(--font-size-sm);
}

.result-card.total-increase:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

/* ==========================================
   VIEW TOGGLE (ANNUAL/MONTHLY)
   ========================================== */

.view-toggle-container {
    display: flex;
    justify-content: center;
    margin-bottom: var(--spacing-lg);
}

.view-toggle-label {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--color-text-secondary);
}

.view-toggle {
    position: relative;
    width: 60px;
    height: 30px;
    background: #cccccc;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: background var(--transition-base);
    padding: 0;
}

.view-toggle[aria-checked="true"] {
    background: var(--color-primary);
}

.toggle-slider {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    background: white;
    border-radius: 50%;
    transition: transform var(--transition-base);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.view-toggle[aria-checked="true"] .toggle-slider {
    transform: translateX(30px);
}

.view-toggle:hover {
    box-shadow: 0 0 8px rgba(227, 6, 19, 0.3);
}

.view-toggle:focus {
    outline: 3px solid var(--color-primary);
    outline-offset: 2px;
}


/* ==========================================
   INFO BOX
   ========================================== */

.info-box {
    grid-column: 1 / -1;
    background: rgba(227, 6, 19, 0.05);
    border-left: 4px solid var(--color-primary);
    border-radius: var(--radius-sm);
    padding: var(--spacing-md);
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

.info-box strong {
    color: var(--color-primary);
}

/* ==========================================
   FOOTER
   ========================================== */

.footer {
    text-align: center;
    margin-top: var(--spacing-xl);
    padding-top: var(--spacing-lg);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}

.footer-nav {
    display: flex;
    justify-content: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
    flex-wrap: wrap;
}

.footer-nav a {
    color: var(--color-text-muted);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.footer-nav a:hover {
    color: var(--color-primary);
    text-decoration: underline;
}

.footer-accessibility {
    margin-top: var(--spacing-sm);
    font-size: 0.8rem;
    color: var(--color-text-muted);
    /* opacity: 0.8; Removed opacity to make image clear */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.footer p a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 600;
}

.footer p a:hover {
    text-decoration: underline;
}

/* ==========================================
   ANIMATIONS
   ========================================== */

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ==========================================
   RESPONSIVE DESIGN
   ========================================== */

@media (max-width: 768px) {
    .container {
        padding: var(--spacing-md);
    }

    .title {
        font-size: var(--font-size-3xl);
        flex-direction: column;
        gap: var(--spacing-xs);
    }

    .subtitle {
        font-size: var(--font-size-base);
    }

    .calculator-card,
    .results-section {
        padding: var(--spacing-lg);
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .results-grid {
        grid-template-columns: 1fr;
    }

    .result-amount {
        font-size: var(--font-size-2xl);
    }

    .modal-content {
        max-width: 800px;
    }

    .header-logo {
        max-width: 150px;
    }

    /* Ensure touch targets are adequate on mobile */
    .form-select,
    .form-input,
    .btn-calculate {
        min-height: 44px;
    }

    /* On mobile, stack the back link normally or adjust position */
    .header {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .back-link {
        position: static;
        margin-bottom: var(--spacing-md);
        align-self: flex-start;
    }
}

@media (max-width: 480px) {
    .title {
        font-size: var(--font-size-2xl);
    }

    .title-icon {
        font-size: var(--font-size-3xl);
    }

    .card-title {
        font-size: var(--font-size-xl);
    }

    .calculator-card,
    .results-section {
        padding: var(--spacing-md);
    }

    .header-logo {
        max-width: 120px;
    }

    .title {
        font-size: var(--font-size-xl);
    }
}

/* ==========================================
   LANDING PAGE (HOME) GRID
   ========================================== */

.home-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--spacing-lg);
    margin-top: var(--spacing-xl);
}

.home-card {
    background: var(--color-bg-card);
    border: 2px solid var(--color-secondary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    text-align: center;
    text-decoration: none;
    color: var(--color-text-primary);
    transition: all var(--transition-base);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
    box-shadow: var(--shadow-md);
}

.home-card:hover {
    transform: translateY(-8px);
    border-color: var(--color-primary);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.home-card-icon {
    /* font-size: 4rem;  Adjusted for material icons if needed, but 4rem ok for container */
    margin-bottom: var(--spacing-sm);
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
}

.home-card-icon .material-symbols-outlined {
    font-size: 4rem;
}

.home-card-title {
    font-size: var(--font-size-xl);
    font-weight: 700;
    line-height: 1.3;
}

.home-card-arrow {
    margin-top: auto;
    font-size: var(--font-size-2xl);
    color: var(--color-primary);
    font-weight: 700;
    opacity: 0;
    transform: translateX(-10px);
    transition: all var(--transition-base);
}

.home-card:hover .home-card-arrow {
    opacity: 1;
    transform: translateX(0);
}

/* ==========================================
   BACK LINK
   ========================================== */

.back-link {
    position: absolute;
    top: 0;
    left: 0;
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    /* margin: var(--spacing-md) var(--spacing-lg); Remove margin as it is absolute now */
    padding: var(--spacing-sm) var(--spacing-md);
    background: white;
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 600;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(227, 6, 19, 0.2);
    transition: all var(--transition-base);
}

.back-link:hover {
    background: var(--color-primary);
    color: white;
    transform: translateX(-4px);
    box-shadow: var(--shadow-md);
    text-decoration: none;
}

/* Response fix for home grid on mobile */
@media (max-width: 600px) {
    .home-grid {
        grid-template-columns: 1fr;
    }

    .back-link {
        position: relative;
        display: inline-flex;
        margin-bottom: var(--spacing-md);
        width: fit-content;
    }
}

/* ==========================================
   MODAL STYLES
   ========================================== */

.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

/* Open state handled by JS via inline style or class toggle, 
   but we can support a class .is-open if we wanted to move away from inline display completely. 
   For now, we keep the JS display toggle but move static styles here. */

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    max-width: 600px;
    /* Increased max-width to accommodate side-by-side */
    width: 90%;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.modal-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;
    /* Default mobile stacked */
}

@media (min-width: 768px) {
    .modal-grid {
        grid-template-columns: 1fr 1fr;
        /* Side-by-side on desktop */
    }
}




.modal-close-btn {
    margin-top: 1.5rem;
    padding: 0.5rem 1rem;
    border: none;
    background: #eee;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    align-self: center;
}


/* ==========================================
   DYNAMIC FIELDS STYLING
   ========================================== */

.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-xs);
}

.radio-group label,
.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-md);
    background: var(--color-bg-input);
    border: 2px solid #e0e0e0;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-weight: 500;
    color: var(--color-text-secondary);
    user-select: none;
}

.radio-group label:hover,
.checkbox-label:hover {
    border-color: var(--color-primary);
    transform: translateY(-1px);
}

/* Style for selected state using :has */
.radio-group label:has(input:checked),
.checkbox-label:has(input:checked) {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary-dark);
    box-shadow: 0 2px 4px rgba(227, 6, 19, 0.3);
}

.radio-group input,
.checkbox-label input {
    accent-color: white;
    width: 1.2em;
    height: 1.2em;
}

/* Specific spacing for CyL options as requested */
.radio-group.cyl-gap {
    gap: 3rem;
    /* Significantly larger gap */
}