/* ==========================================================================
   FINANCIAL CALCULATORS HUB - MODERN DESIGN SYSTEM & STYLES
   ========================================================================== */

:root {
    /* Color Palette - Light Mode */
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --primary-ring: rgba(79, 70, 229, 0.2);

    --secondary: #10b981;
    --secondary-hover: #059669;
    --secondary-light: #ecfdf5;

    --accent: #f59e0b;
    --accent-light: #fffbeb;

    --danger: #ef4444;
    --danger-light: #fef2f2;

    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-subtle: #f1f5f9;
    --bg-hover: #e2e8f0;

    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;

    --border-color: #e2e8f0;
    --border-focus: #4f46e5;

    --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-glow: 0 0 20px rgba(79, 70, 229, 0.15);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    --font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    /* Color Palette - Dark Mode */
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: rgba(99, 102, 241, 0.15);
    --primary-ring: rgba(99, 102, 241, 0.3);

    --secondary: #34d399;
    --secondary-hover: #10b981;
    --secondary-light: rgba(52, 211, 153, 0.15);

    --accent: #fbbf24;
    --accent-light: rgba(251, 191, 36, 0.15);

    --danger: #f87171;
    --danger-light: rgba(248, 113, 113, 0.15);

    --bg-main: #0b0f19;
    --bg-card: #151d2f;
    --bg-subtle: #1e293b;
    --bg-hover: #27354f;

    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-light: #64748b;

    --border-color: #1e293b;
    --border-focus: #6366f1;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.25);
}

/* ==========================================================================
   BASE & RESET
   ========================================================================== */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    transition: background-color var(--transition-normal), color var(--transition-normal);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
    background: none;
}

input, select {
    font-family: inherit;
    outline: none;
}

/* ==========================================================================
   NAVBAR & HEADER
   ========================================================================== */

.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(8px);
    box-shadow: var(--shadow-sm);
}

.header-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0.85rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-main);
    cursor: pointer;
}

.logo-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    color: #ffffff;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

.logo-text span {
    color: var(--primary);
}


.nav-links {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-link {
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.9rem;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.nav-link:hover, .nav-link.active {
    color: var(--primary);
    background-color: var(--primary-light);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Control Selectors (Currency & Theme) */
.custom-select-wrapper {
    position: relative;
}

.currency-select {
    padding: 0.45rem 1.75rem 0.45rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background-color: var(--bg-subtle);
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    appearance: none;
    transition: all var(--transition-fast);
}

.currency-select:hover, .currency-select:focus {
    border-color: var(--primary);
}

.select-arrow {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    font-size: 0.65rem;
    color: var(--text-muted);
}

.theme-toggle-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background-color: var(--bg-subtle);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all var(--transition-fast);
}

.theme-toggle-btn:hover {
    background-color: var(--bg-hover);
    color: var(--primary);
}

/* ==========================================================================
   APP CONTAINER & LAYOUT
   ========================================================================== */

.app-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    flex: 1;
    width: 100%;
}

/* Hero Section */
.hero-section {
    text-align: center;
    margin-bottom: 2.5rem;
    padding: 2.5rem 1.5rem;
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-subtle) 100%);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, var(--primary-ring) 0%, transparent 60%);
    pointer-events: none;
}

.hero-title {
    font-size: 2.25rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
    background: linear-gradient(135deg, var(--text-main), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-subtitle {
    font-size: 1.1rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto;
}



/* Hub Cards Grid */
.hub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.calc-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    position: relative;
}

.calc-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}

.calc-card-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.calc-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background-color: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    flex-shrink: 0;
}

.calc-card-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.25rem;
}

.calc-card-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.calc-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.calc-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.65rem;
    border-radius: var(--radius-full);
    background-color: var(--bg-subtle);
    color: var(--text-muted);
}

.calc-card-action {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.calc-card:hover .calc-card-action {
    transform: translateX(3px);
    transition: transform var(--transition-fast);
}

/* ==========================================================================
   ACTIVE CALCULATOR VIEW / PANEL
   ========================================================================== */

.calc-panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

.calc-panel.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.panel-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.breadcrumb-btn {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
}

.breadcrumb-btn:hover {
    text-decoration: underline;
}

.calculator-layout {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 2rem;
    align-items: start;
}

/* Input Form Section */
.calc-input-section {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    box-shadow: var(--shadow-sm);
}

.calc-title-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.75rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.calc-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

.calc-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon-action {
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    background-color: var(--bg-subtle);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    transition: all var(--transition-fast);
}

.btn-icon-action:hover {
    background-color: var(--bg-hover);
    color: var(--primary);
}

/* Control Group / Input Row */
.input-group {
    margin-bottom: 1.5rem;
}

.input-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.65rem;
}

.input-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
}

.input-box-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-prefix, .input-suffix {
    position: absolute;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    pointer-events: none;
}

.input-prefix { left: 0.75rem; }
.input-suffix { right: 0.75rem; }

.number-input {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background-color: var(--bg-subtle);
    color: var(--text-main);
    font-size: 0.95rem;
    font-weight: 600;
    text-align: right;
    width: 155px;
    transition: all var(--transition-fast);
}

.number-input.has-prefix { padding-left: 1.85rem; }
.number-input.has-suffix { padding-right: 1.85rem; }

.number-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
    background-color: var(--bg-card);
}

/* Slider Controls */
.range-slider-container {
    margin-top: 0.65rem;
}

.range-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: var(--radius-full);
    background: var(--bg-hover);
    outline: none;
    cursor: pointer;
    transition: background 0.15s;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.4);
    border: 2px solid #ffffff;
    transition: transform var(--transition-fast);
}

.range-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.4);
    border: 2px solid #ffffff;
    transition: transform var(--transition-fast);
}

.range-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.slider-scale {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 0.35rem;
}

/* Toggle Buttons / Segmented Controls */
.segmented-control {
    display: flex;
    background-color: var(--bg-subtle);
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    gap: 0.25rem;
    margin-bottom: 1.25rem;
}

.segment-btn {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-align: center;
    transition: all var(--transition-fast);
}

.segment-btn.active {
    background-color: var(--bg-card);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* Output / Result Summary Section */
.calc-result-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.result-card-highlight {
    background: linear-gradient(135deg, var(--primary) 0%, #4338ca 100%);
    color: #ffffff;
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    box-shadow: var(--shadow-glow);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.highlight-label {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.85;
    margin-bottom: 0.4rem;
}

.highlight-value {
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

.highlight-subtext {
    font-size: 0.85rem;
    opacity: 0.8;
}

.breakdown-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

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

.breakdown-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.breakdown-item-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.dot-primary { background-color: var(--primary); }
.dot-secondary { background-color: var(--secondary); }
.dot-accent { background-color: var(--accent); }

.breakdown-item-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
}

.chart-container-donut {
    position: relative;
    height: 220px;
    margin-top: 1rem;
}

.chart-container-bar {
    position: relative;
    height: 280px;
    margin-top: 1.5rem;
}

/* Tables / Amortization Schedule */
.schedule-section {
    margin-top: 2rem;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

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

.schedule-title {
    font-size: 1.15rem;
    font-weight: 700;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    max-height: 400px;
    position: relative;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: right;
}

.data-table th, .data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    position: sticky;
    top: 0;
    background-color: var(--bg-subtle);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    z-index: 10;
}

.data-table th:first-child, .data-table td:first-child {
    text-align: left;
}

.data-table tbody tr:hover {
    background-color: var(--bg-subtle);
}

/* ==========================================================================
   FOOTER
   ========================================================================== */

.site-footer {
    background-color: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: 2rem 1.5rem;
    margin-top: auto;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.footer-container {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.footer-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-disclaimer {
    font-size: 0.78rem;
    line-height: 1.5;
    color: var(--text-light);
    max-width: 800px;
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */

@media print {
    .site-header, .panel-breadcrumb, .btn-icon-action, .site-footer {
        display: none !important;
    }

    body, .app-container {
        background: #ffffff !important;
        color: #000000 !important;
        padding: 0 !important;
    }

    .calc-input-section, .breakdown-card, .schedule-section {
        box-shadow: none !important;
        border: 1px solid #cccccc !important;
    }

    .table-responsive {
        max-height: none !important;
        overflow: visible !important;
    }
}

/* ==========================================================================
   RESPONSIVE DESIGN (MOBILE / TABLET)
   ========================================================================== */

@media (max-width: 900px) {
    .calculator-layout {
        grid-template-columns: 1fr;
    }
    
    .nav-links {
        display: none;
    }

    .hero-title {
        font-size: 1.85rem;
    }
}

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