/* === 1. GLOBAL RESETS & THEME VARIABLES === */
:root {
    /* The "C.I.S." Palette */
    --bg-main: #F8FAFC;         /* Soft slate background - stays easy on eyes */
    --card-bg: #FFFFFF;
    --text-main: #0F172A;       /* Deep Navy for authority */
    --text-muted: #64748B;
    --primary: #00FFAB;         /* Growth Green - triggers "success" dopamine */
    --accent: #007AFF;          /* Action Blue - builds trust */
    --border: #E2E8F0;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    overflow-x: hidden;
}

body { 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; 
    background: var(--bg-main); 
    margin: 0;
    padding: 0; 
    display: flex; 
    flex-direction: column;
    align-items: center; 
    min-height: 100vh;
    overflow-x: hidden;
    color: var(--text-main);
}

/* === CENTERED SCALABLE HEADER === */
header {
    display: flex;
    flex-direction: column;
    align-items: center; 
    text-align: center;
    width: 100%;
    margin-bottom: 24px;
}

h1 {
    font-size: clamp(1.4rem, 5vw, 1.8rem); /* Dynamically scales with screen size */
    font-weight: 800;
    color: var(--text-main);
    margin: 0;
    letter-spacing: -0.5px;
    width: 100%;
    word-wrap: break-word;
}

.subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 6px;
    max-width: 280px; /* Keeps text from getting too wide on desktop */
}

/* === 8. RESULTS DISPLAY (The "Hook") === */
.result { 
    margin-top: 28px; 
    padding: 24px; 
    background: var(--text-main); /* Deep Navy box for focus */
    border-radius: 20px; 
    text-align: center; 
    color: white; 
    box-shadow: 0 15px 30px rgba(15, 23, 42, 0.2);
}

.result-val { 
    font-size: 36px; 
    font-weight: 900; 
    margin-bottom: 8px;
    color: white; /* Stays white unless annualRate is negative in JS */
}

.chart-bar-actual {
    height: 100%;
    background: var(--primary); /* Mint green suggests wealth accumulation */
    transition: width 0.8s cubic-bezier(0.34, 1.56, 0.64, 1); /* Bouncy "Growth" effect */
}

/* Specifically target the checkbox to override browser defaults */
input[type="checkbox"]#inflation-toggle {
    appearance: auto; /* Ensures the browser uses the accent-color logic */
    accent-color: #00FFAB !important; /* The !important ensures your theme wins */
    width: 20px;
    height: 20px;
    cursor: pointer;
    vertical-align: middle;
}

/* === 2. LAYOUT CONTAINERS === */
.app-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: 20px;
    /* Extra space so content clears the sticky ad */
    padding-bottom: 100px; 
}

.card { 
    background: #FFFFFF; 
    padding: clamp(20px, 5vw, 32px); 
    border-radius: 24px; 
    box-shadow: 0 10px 40px rgba(15, 23, 42, 0.08); 
    width: 100%;
    max-width: 440px; 
    margin: 20px auto;
    transition: box-shadow 0.3s ease, border 0.3s ease;
    will-change: box-shadow, transform;
}

.divider {
    border: 0;
    border-top: 1.5px solid #F1F5F9;
    margin: 24px 0;
}

/* === 3. TAB NAVIGATION === */
.tabs {
    display: flex;
    background: #F1F5F9;
    padding: 4px;
    border-radius: 12px;
    margin-bottom: 24px;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    color: #64748B;
    transition: all 0.2s ease;
}

.tab-btn.active {
    background: #FFFFFF;
    color: #0F172A;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.1);
}

/* === 4. INPUT STYLES === */
.input-group { margin-bottom: 20px; }

.input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

label { 
    display: block; 
    font-size: 12px; 
    color: #64748B; 
    margin-bottom: 6px; 
    font-weight: 700; 
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input, select { 
    width: 100%; 
    padding: 12px; 
    border: 1.5px solid #E2E8F0; 
    border-radius: 12px; 
    font-size: 16px; 
    background-color: #F8FAFC; 
    color: #0F172A;
    transition: border-color 0.2s;
}

input:focus, select:focus {
    outline: none;
    border-color: #007AFF;
}

input:disabled {
    background-color: #F1F5F9 !important;
    color: #94A3B8;
    cursor: not-allowed;
    font-weight: 600;
}

/* === 5. SIMULATOR SPECIFIC STYLES === */
.search-wrapper {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.chip-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.ticker-chip {
    background: #0F172A;
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slideUp 0.3s ease-out;
}

.remove-ticker {
    color: #CBD5E1; /* Lighter grey for better visibility */
    cursor: pointer;
    font-size: 14px;
    padding: 2px;
    transition: color 0.2s;
}

.remove-ticker:hover {
    color: #FF8080; /* Turns soft red when hovering to delete */
}

.data-badge {
    background: #E0F2FE;
    color: #0369A1;
    padding: 12px;
    border-radius: 12px;
    font-size: 12px;
    line-height: 1.5;
    margin: 10px 0;
    border-left: 4px solid #0EA5E9;
}

/* === 6. BUTTONS === */
.btn-primary { 
    width: 100%; 
    padding: 16px; 
    background: #00FFAB; 
    color: #0F172A; 
    border: none; 
    border-radius: 14px; 
    font-size: 17px; 
    font-weight: 800; 
    cursor: pointer; 
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(0, 255, 171, 0.3);
}

.btn-secondary {
    background: #0F172A;
    color: white;
    border: none;
    border-radius: 10px;
    padding: 0 16px;
    cursor: pointer;
    font-weight: 600;
}

button:active { transform: scale(0.97); }

.btn-share {
    width: 100%;
    padding: 14px;
    background: #007AFF; /* Distinct iOS-style Blue */
    color: white;
    border: none;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.2);
}

.btn-share:hover {
    background: #0063CC;
    transform: translateY(-1px);
}

.btn-share:active {
    transform: scale(0.98);
}

/* Success animation for the clipboard */
.copied {
    background: #28a745 !important;
}

/* Tooltip Container */
.tooltip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: help;
    
    /* The Circle Styling */
    width: 16px;
    height: 16px;
    background-color: #E2E8F0; /* Light grey circle */
    color: #64748B; /* Slate grey text */
    border-radius: 50%;
    
    font-size: 11px;
    margin-left: 6px;
    font-weight: 700;
    transition: all 0.2s ease;
    vertical-align: middle;
}

.tooltip:hover {
    background-color: #007AFF; /* Turns blue on hover */
    color: #FFFFFF;
}

/* Tooltip Text (Hidden by default) */
.tooltip::after {
    content: attr(data-tip);
    position: absolute;
    bottom: 150%;
    left: 50%;
    transform: translateX(-50%);
    width: 180px;
    padding: 10px;
    background-color: #1E293B;
    color: #fff;
    font-size: 11px;
    font-weight: 400;
    line-height: 1.4;
    border-radius: 8px;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.tooltip:hover::after {
    visibility: visible;
    opacity: 1;
}

/* Tooltip Arrow */
.tooltip::before {
    content: "";
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: #0F172A transparent transparent transparent;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 999;
}

/* Show on Hover/Tap */
.tooltip:hover::after, 
.tooltip:hover::before {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(-5px);
}

/* === 7. HELP & TICKER GUIDES === */
.ticker-guide {
    margin: 15px 0;
    background: #F8FAFC;
    border: 1px solid #E2E8F0;
    border-radius: 12px;
    font-size: 13px;
}

.ticker-guide summary {
    padding: 12px;
    cursor: pointer;
    font-weight: 600;
    color: #475569;
    list-style: none;
}

.guide-content {
    padding: 0 12px 12px 12px;
    color: #64748B;
    line-height: 1.6;
}

/* Skeleton Chip Styling */
.skeleton-chip {
    background: #E2E8F0;
    width: 80px;
    height: 32px;
    border-radius: 20px;
    position: relative;
    overflow: hidden;
}

/* The Pulsing Animation */
.skeleton-chip::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
    animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* === 8. RESULTS DISPLAY === */
.result { 
    margin-top: 28px; 
    padding: 24px; 
    background: #0F172A; 
    border-radius: 18px; 
    text-align: center; 
    color: white; 
}

.result-val { font-size: 32px; font-weight: 800; margin-bottom: 8px; }

.milestone-note {
    background: rgba(255, 255, 255, 0.08);
    padding: 12px;
    border-radius: 10px;
    font-size: 13px;
    margin-top: 15px;
    border-left: 3px solid #00FFAB;
}

.warning-note { color: #FF8080; font-size: 12px; margin-top: 12px; }

.chart-bar-bg {
    width: 100%;
    height: 24px;
    background: #334155; /* Darker background for the bar */
    border-radius: 12px;
    display: flex;
    overflow: hidden;
    margin: 10px 0;
}

.chart-bar-actual {
    height: 100%;
    background: #00FFAB; /* Your primary theme color */
    transition: width 0.8s ease-out;
}

.chart-bar-lost {
    height: 100%;
    background: #FF4D4D; /* Red for the "loss" */
    transition: width 0.8s ease-out;
}

.chart-legend {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: #94A3B8;
    margin-top: 5px;
}

.chart-legend small { margin-right: 4px; font-size: 14px; }

/* Shake animation for errors */
.shake {
    animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
    border-color: #FF4D4D !important;
}

@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* Success Glow Animation */
.success-glow {
    animation: glow-green 1s ease-out;
}

@keyframes glow-green {
    0% { box-shadow: 0 10px 40px rgba(15, 23, 42, 0.08); }
    50% { box-shadow: 0 0 20px rgba(0, 255, 171, 0.6); border: 1px solid #00FFAB; }
    100% { box-shadow: 0 10px 40px rgba(15, 23, 42, 0.08); }
}

/* === 9. STICKY AD & FOOTER === */
.ad-sticky-container {
    position: fixed;
    bottom: 0;
    width: 100%;
    /* Solid background ensures ad doesn't overlap text */
    background: #FFFFFF; 
    border-top: 1px solid #E2E8F0;
    padding: 10px;
    display: flex;
    justify-content: center;
    z-index: 1000;
}

.ad-slot {
    width: 100%;
    max-width: 320px;
    height: 50px;
    background: #F1F5F9;
    border: 1px dashed #CBD5E1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #94A3B8;
}

.legal-footer {
    width: 100%;
    max-width: 440px;
    /* Added bottom padding to clear the fixed ad container */
    padding: 20px 20px 100px 20px; 
    text-align: center;
    font-size: 11px;
    color: #94A3B8;
    line-height: 1.6;
}

.footer-links {
    margin-bottom: 12px;
    display: flex;
    justify-content: center;
    gap: 15px;
}

.footer-links a {
    color: #64748B;
    text-decoration: none;
    font-weight: 600;
}

.hidden { display: none !important; }

@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Custom Checkbox */
#inflation-toggle {
    width: 18px;
    height: 18px;
    accent-color: #007AFF;
    cursor: pointer;
}