/* ==========================================================================
   main.css - Global Design System for Loan Calculator Online
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Custom Properties
   -------------------------------------------------------------------------- */
:root {
    /* Colors */
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --secondary: #059669;
    --secondary-dark: #047857;
    --secondary-light: #d1fae5;
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --text-lighter: #94a3b8;
    --border: #e2e8f0;
    --border-dark: #cbd5e1;
    --error: #dc2626;
    --error-light: #fef2f2;
    --success: #16a34a;
    --success-light: #f0fdf4;
    --warning: #d97706;
    --warning-light: #fffbeb;

    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-family-mono: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', 'Courier New', monospace;

    /* Spacing scale (4px base) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;

    /* Border radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

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

    /* Breakpoints (for reference; actual media queries below) */
    --breakpoint-md: 768px;
    --breakpoint-lg: 1024px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;
}

/* --------------------------------------------------------------------------
   CSS Reset
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

* {
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: var(--font-family);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text);
    background-color: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img,
picture,
video,
canvas,
svg {
    display: block;
    max-width: 100%;
}

input,
button,
textarea,
select {
    font: inherit;
}

p,
h1,
h2,
h3,
h4,
h5,
h6 {
    overflow-wrap: break-word;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

ul,
ol {
    list-style: none;
}

table {
    border-collapse: collapse;
    border-spacing: 0;
}

/* --------------------------------------------------------------------------
   Screen Reader Only
   -------------------------------------------------------------------------- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.sr-only-focusable:focus {
    position: static;
    width: auto;
    height: auto;
    padding: inherit;
    margin: inherit;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* --------------------------------------------------------------------------
   Skip Navigation
   -------------------------------------------------------------------------- */
.skip-nav {
    position: absolute;
    top: -100%;
    left: var(--space-4);
    background: var(--primary);
    color: #fff;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-sm);
    z-index: 10000;
    font-weight: 600;
    text-decoration: none;
}

.skip-nav:focus {
    top: var(--space-4);
    color: #fff;
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */
.container {
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--space-5);
    padding-right: var(--space-5);
}

.grid-2col {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-6);
}

@media (min-width: 768px) {
    .grid-2col {
        grid-template-columns: 1fr 1fr;
    }
}

/* --------------------------------------------------------------------------
   Typography
   -------------------------------------------------------------------------- */
h1 {
    font-size: clamp(1.75rem, 5vw, 2.5rem);
    line-height: 1.2;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

h2 {
    font-size: clamp(1.5rem, 4vw, 2rem);
    line-height: 1.25;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}

h3 {
    font-size: 1.5rem;
    line-height: 1.7;
    font-weight: 600;
    color: var(--text);
}

h4 {
    font-size: 1.25rem;
    line-height: 1.5;
    font-weight: 600;
    color: var(--text);
}

p {
    margin-bottom: var(--space-4);
    color: var(--text);
}

.text-sm {
    font-size: 0.875rem;
}

.text-lg {
    font-size: 1.125rem;
}

.text-xl {
    font-size: 1.25rem;
}

.text-muted {
    color: var(--text-light);
}

.text-center {
    text-align: center;
}

.text-mono {
    font-family: var(--font-family-mono);
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    user-select: none;
}

.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Primary button */
.btn-primary,
.btn {
    background-color: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

.btn-primary:hover,
.btn:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #ffffff;
    text-decoration: none;
}

.btn-primary:active,
.btn:active {
    transform: translateY(1px);
}

/* Outline button */
.btn-outline {
    background-color: transparent;
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline:hover {
    background-color: var(--primary);
    color: #ffffff;
    text-decoration: none;
}

/* Secondary button */
.btn-secondary {
    background-color: var(--secondary);
    color: #ffffff;
    border-color: var(--secondary);
}

.btn-secondary:hover {
    background-color: var(--secondary-dark);
    border-color: var(--secondary-dark);
    color: #ffffff;
    text-decoration: none;
}

/* Small button */
.btn-sm {
    padding: var(--space-1) var(--space-3);
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
}

/* Large button */
.btn-lg {
    padding: var(--space-4) var(--space-8);
    font-size: 1.125rem;
}

/* Button group */
.btn-group {
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */
.card {
    background-color: var(--surface);
    box-shadow: var(--shadow-md);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    transition: box-shadow var(--transition-base);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-flat {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background-color: var(--surface);
    box-shadow: var(--shadow-sm);
}

.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.site-logo {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
}

.site-logo:hover {
    color: var(--primary);
    text-decoration: none;
}

.site-logo svg,
.site-logo img {
    width: 32px;
    height: 32px;
}

/* Desktop navigation */
.main-nav {
    display: none;
}

.main-nav ul {
    display: flex;
    align-items: center;
    gap: var(--space-6);
}

.main-nav a {
    color: var(--text-light);
    font-size: 0.9375rem;
    font-weight: 500;
    text-decoration: none;
    padding: var(--space-2) 0;
    transition: color var(--transition-fast);
}

.main-nav a:hover,
.main-nav a.active {
    color: var(--primary);
    text-decoration: none;
}

@media (min-width: 768px) {
    .main-nav {
        display: flex;
    }
}

/* Mobile hamburger menu */
.menu-toggle {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    color: var(--text);
}

.menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background-color: var(--text);
    border-radius: 1px;
    transition: all var(--transition-fast);
}

@media (min-width: 768px) {
    .menu-toggle {
        display: none;
    }
}

/* Mobile nav overlay */
.mobile-nav {
    display: none;
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--surface);
    z-index: 999;
    padding: var(--space-6) var(--space-5);
    overflow-y: auto;
}

.mobile-nav.is-open {
    display: block;
}

.mobile-nav ul {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.mobile-nav a {
    display: block;
    padding: var(--space-3) var(--space-4);
    color: var(--text);
    font-size: 1.125rem;
    font-weight: 500;
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: background-color var(--transition-fast);
}

.mobile-nav a:hover {
    background-color: var(--bg);
    color: var(--primary);
    text-decoration: none;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.site-footer {
    background-color: var(--text);
    color: #ffffff;
    padding: var(--space-12) 0 var(--space-6);
    margin-top: var(--space-16);
}

.site-footer .container {
    display: flex;
    flex-direction: column;
    gap: var(--space-8);
}

.footer-top {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-8);
}

@media (min-width: 768px) {
    .footer-top {
        grid-template-columns: 2fr 1fr 1fr 1fr;
    }
}

.footer-brand {
    max-width: 320px;
}

.footer-brand p {
    color: #94a3b8;
    font-size: 0.875rem;
    line-height: 1.7;
}

.footer-heading {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    margin-bottom: var(--space-4);
}

.footer-links {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.footer-links a {
    color: #cbd5e1;
    font-size: 0.875rem;
    text-decoration: none;
    transition: color var(--transition-fast);
}

.footer-links a:hover {
    color: #ffffff;
    text-decoration: none;
}

.footer-bottom {
    border-top: 1px solid #334155;
    padding-top: var(--space-6);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
    text-align: center;
}

@media (min-width: 768px) {
    .footer-bottom {
        flex-direction: row;
        justify-content: space-between;
    }
}

.footer-copyright {
    color: #94a3b8;
    font-size: 0.8125rem;
}

.footer-bottom-links {
    display: flex;
    gap: var(--space-4);
}

.footer-bottom-links a {
    color: #94a3b8;
    font-size: 0.8125rem;
    text-decoration: none;
}

.footer-bottom-links a:hover {
    color: #ffffff;
}

/* --------------------------------------------------------------------------
   Cookie Consent Banner
   -------------------------------------------------------------------------- */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background-color: var(--surface);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.12);
    padding: var(--space-4) var(--space-5);
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
}

.cookie-banner.active {
    display: flex;
}

.cookie-banner p {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 0;
    flex: 1 1 auto;
    min-width: 200px;
}

.cookie-banner a {
    color: var(--primary);
    text-decoration: underline;
}

.cookie-banner .btn-group {
    flex-shrink: 0;
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.cookie-banner .btn {
    font-size: 0.8125rem;
    padding: var(--space-2) var(--space-4);
}

/* Cookie customization modal */
.cookie-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
}

.cookie-modal {
    background-color: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-width: 520px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    padding: var(--space-6);
}

.cookie-modal h3 {
    margin-bottom: var(--space-4);
}

.cookie-category {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--border);
}

.cookie-category:last-child {
    border-bottom: none;
}

.cookie-category-info h4 {
    font-size: 0.9375rem;
    font-weight: 600;
}

.cookie-category-info p {
    font-size: 0.8125rem;
    color: var(--text-light);
    margin-bottom: 0;
}

.cookie-toggle {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.cookie-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.cookie-toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-dark);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.cookie-toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background-color: #ffffff;
    border-radius: 50%;
    transition: transform var(--transition-fast);
}

.cookie-toggle input:checked + .cookie-toggle-slider {
    background-color: var(--primary);
}

.cookie-toggle input:checked + .cookie-toggle-slider::before {
    transform: translateX(20px);
}

.cookie-toggle input:disabled + .cookie-toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

/* --------------------------------------------------------------------------
   Breadcrumb
   -------------------------------------------------------------------------- */
.breadcrumb {
    padding: var(--space-4) 0;
    font-size: 0.875rem;
}

.breadcrumb ol {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1);
}

.breadcrumb li {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.breadcrumb li + li::before {
    content: '/';
    color: var(--text-lighter);
    margin-right: var(--space-1);
}

.breadcrumb a {
    color: var(--text-light);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--primary);
    text-decoration: underline;
}

.breadcrumb .current {
    color: var(--text);
    font-weight: 500;
}

/* --------------------------------------------------------------------------
   Section Spacing Utilities
   -------------------------------------------------------------------------- */
.section {
    padding: var(--space-12) 0;
}

.section-sm {
    padding: var(--space-8) 0;
}

.section-lg {
    padding: var(--space-16) 0;
}

.section-title {
    margin-bottom: var(--space-2);
}

.section-subtitle {
    color: var(--text-light);
    font-size: 1.125rem;
    margin-bottom: var(--space-8);
}

/* --------------------------------------------------------------------------
   Utility Classes
   -------------------------------------------------------------------------- */
.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.flex-wrap {
    flex-wrap: wrap;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-2 {
    gap: var(--space-2);
}

.gap-4 {
    gap: var(--space-4);
}

.gap-6 {
    gap: var(--space-6);
}

.mt-4 {
    margin-top: var(--space-4);
}

.mt-6 {
    margin-top: var(--space-6);
}

.mt-8 {
    margin-top: var(--space-8);
}

.mb-4 {
    margin-bottom: var(--space-4);
}

.mb-6 {
    margin-bottom: var(--space-6);
}

.mb-8 {
    margin-bottom: var(--space-8);
}

.mx-auto {
    margin-left: auto;
    margin-right: auto;
}

.w-full {
    width: 100%;
}

.max-w-prose {
    max-width: 65ch;
}

.hidden {
    display: none;
}

/* --------------------------------------------------------------------------
   Responsive Adjustments
   -------------------------------------------------------------------------- */
@media (max-width: 767px) {
    h1 {
        font-size: 2rem;
        line-height: 2.4;
    }

    h2 {
        font-size: 1.5rem;
        line-height: 1.8;
    }

    h3 {
        font-size: 1.25rem;
        line-height: 1.6;
    }

    .container {
        padding-left: var(--space-4);
        padding-right: var(--space-4);
    }

    .section {
        padding: var(--space-8) 0;
    }

    .section-lg {
        padding: var(--space-10) 0;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .container {
        max-width: 100%;
    }
}
