/* Market Cycle Tracker Styles */
:root {
    /* Color scheme based on valuation levels */
    --attractive-color: #22c55e;      /* Green - cheap */
    --fair-color: #f59e0b;           /* Amber - fair value */
    --expensive-color: #ef4444;       /* Red - expensive */
    --very-expensive-color: #dc2626;  /* Dark red - very expensive */
    
    /* Neutral colors */
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --border-color: #e5e7eb;
    --card-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    
    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 40px;
    padding: 40px 0;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    border-radius: 12px;
    box-shadow: var(--card-shadow);
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Gauge Section */
.gauge-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 40px;
    padding: 40px;
    background: var(--bg-primary);
    border-radius: 16px;
    box-shadow: var(--card-shadow);
}

.gauge-container {
    position: relative;
    margin-bottom: 24px;
}

.gauge-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: var(--card-shadow);
}

.current-reading {
    text-align: center;
    margin-top: 16px;
}

.pe-value {
    display: block;
    font-size: 3rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-mono);
}

.pe-label {
    display: block;
    font-size: 1rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Status Badge */
.status-badge {
    padding: 12px 24px;
    border-radius: 24px;
    font-weight: 600;
    font-size: 1.125rem;
    text-align: center;
    min-width: 200px;
}

.status-badge.attractive {
    background-color: rgba(34, 197, 94, 0.1);
    color: var(--attractive-color);
    border: 2px solid var(--attractive-color);
}

.status-badge.fair {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--fair-color);
    border: 2px solid var(--fair-color);
}

.status-badge.expensive {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--expensive-color);
    border: 2px solid var(--expensive-color);
}

.status-badge.very-expensive {
    background-color: rgba(220, 38, 38, 0.1);
    color: var(--very-expensive-color);
    border: 2px solid var(--very-expensive-color);
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.metric-card {
    background: var(--bg-primary);
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px 0 rgb(0 0 0 / 0.15);
}

.metric-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
    font-family: var(--font-mono);
}

.metric-context {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Reference Section */
.reference-section {
    background: var(--bg-primary);
    padding: 32px;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    margin-bottom: 40px;
}

.reference-section h2 {
    font-size: 1.5rem;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.reference-note {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-style: italic;
}

/* Valuation Table */
.valuation-table {
    display: grid;
    grid-template-columns: 1fr 2fr 1.5fr 1.5fr;
    gap: 1px;
    background-color: var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.table-header {
    display: contents;
}

.table-header > span {
    background: var(--text-primary);
    color: white;
    padding: 16px 12px;
    font-weight: 600;
    font-size: 0.875rem;
    text-align: center;
}

.table-row {
    display: contents;
}

.table-row > span {
    background: var(--bg-primary);
    padding: 14px 12px;
    text-align: center;
    font-size: 0.875rem;
}

.table-row.attractive > span:first-child {
    background: rgba(34, 197, 94, 0.1);
    color: var(--attractive-color);
    font-weight: 600;
}

.table-row.fair > span:first-child {
    background: rgba(245, 158, 11, 0.1);
    color: var(--fair-color);
    font-weight: 600;
}

.table-row.expensive > span:first-child {
    background: rgba(239, 68, 68, 0.1);
    color: var(--expensive-color);
    font-weight: 600;
}

.table-row.very-expensive > span:first-child {
    background: rgba(220, 38, 38, 0.1);
    color: var(--very-expensive-color);
    font-weight: 600;
}

/* Chart Section */
.chart-section {
    background: var(--bg-primary);
    padding: 32px;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    margin-bottom: 40px;
}

.chart-section h2 {
    font-size: 1.5rem;
    margin-bottom: 24px;
    color: var(--text-primary);
}

.chart-container {
    position: relative;
    height: 400px;
    margin-bottom: 16px;
    text-align: center;
}

.cycle-chart {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: var(--card-shadow);
}

.chart-note {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: center;
    font-style: italic;
}

/* Context Section */
.context-section {
    margin-bottom: 40px;
}

.context-section h2 {
    font-size: 1.5rem;
    margin-bottom: 24px;
    color: var(--text-primary);
    text-align: center;
}

.context-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.context-card {
    background: var(--bg-primary);
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
}

.context-card h3 {
    font-size: 1.125rem;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.context-card p {
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Footer */
footer {
    background: var(--bg-primary);
    padding: 32px;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    margin-top: 40px;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 32px;
    margin-bottom: 24px;
}

.footer-content h4 {
    font-size: 1rem;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.footer-content ul {
    list-style: none;
}

.footer-content li {
    margin-bottom: 8px;
}

.footer-content a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s ease;
}

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

.disclaimer {
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.disclaimer p {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.5;
}

/* Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--text-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 16px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .pe-value {
        font-size: 2.5rem;
    }
    
    .valuation-table {
        grid-template-columns: 1fr;
    }
    
    .table-header {
        display: none;
    }
    
    .table-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        margin-bottom: 8px;
        padding: 12px;
        background: var(--bg-primary);
        border-radius: 8px;
        border: 1px solid var(--border-color);
    }
    
    .chart-container {
        height: 300px;
    }
    
    .context-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .gauge-section {
        padding: 24px 16px;
    }
    
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    
    .status-badge {
        min-width: unset;
        width: 100%;
        max-width: 300px;
    }
}