/* ============================================
   AU Price Monitor — Unified Design System
   ============================================ */

/* --- CSS Variables --- */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #10b981;
    --secondary-dark: #059669;
    --accent: #f59e0b;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --info: #3b82f6;

    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    --bg-body: #f1f5f9;
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --border-color: #e2e8f0;

    --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
    --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.08), 0 2px 4px -1px rgba(0,0,0,.04);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -2px rgba(0,0,0,.04);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,.08), 0 10px 10px -5px rgba(0,0,0,.03);

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    --transition: all .2s ease;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans SC', sans-serif;
    --font-mono: 'SF Mono', 'Cascadia Code', 'Fira Code', Consolas, monospace;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-sans);
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 15px;
    min-height: 100vh;
}

/* --- Layout --- */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 0 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.content {
    padding: 1.25rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

/* --- Navigation --- */
.site-nav {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-xs);
}

.nav-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-primary);
    text-decoration: none;
}

.nav-brand-icon {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--accent), #fbbf24);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .85rem;
}

.nav-links {
    display: flex;
    gap: .25rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: .375rem;
    padding: .5rem .875rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-size: .875rem;
    font-weight: 500;
    transition: var(--transition);
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.nav-link.active {
    color: var(--primary);
    background: #eef2ff;
    font-weight: 600;
}

.nav-link-icon { font-size: 1rem; }

.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
    padding: .5rem;
    border: none;
    background: none;
}

.nav-toggle span {
    width: 20px;
    height: 2px;
    background: var(--text-secondary);
    border-radius: 2px;
    transition: var(--transition);
}

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

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

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: .25rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.card-desc {
    font-size: .8rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: .75rem;
}

/* --- Type Selector (Tabs) --- */
.type-tabs {
    display: flex;
    background: var(--bg-tertiary);
    padding: 3px;
    border-radius: var(--radius-md);
    width: fit-content;
}

.type-tab {
    background: none;
    border: none;
    padding: .5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: .8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: var(--transition);
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: .375rem;
}

.type-tab.active {
    background: var(--bg-primary);
    color: var(--primary);
    box-shadow: var(--shadow-xs);
}

.type-tab:hover:not(.active) {
    color: var(--text-primary);
}

/* --- Price Card (dual layout) --- */
.price-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

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

.price-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.price-card-name {
    font-size: .9375rem;
    font-weight: 700;
    color: var(--text-primary);
}

.price-badge {
    display: inline-flex;
    align-items: center;
    gap: .2rem;
    padding: .2rem .5rem;
    border-radius: 20px;
    font-size: .7rem;
    font-weight: 600;
    font-family: var(--font-mono);
}

.price-badge.up { background: #dcfce7; color: #16a34a; }
.price-badge.down { background: #fee2e2; color: #dc2626; }
.price-badge.neutral { background: var(--bg-tertiary); color: var(--text-secondary); }

.price-card-body { text-align: center; padding: .25rem 0; }

.price-card-value {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--text-primary);
    font-family: var(--font-mono);
    letter-spacing: -.02em;
    line-height: 1.1;
}

.price-card-unit {
    font-size: .875rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-left: .125rem;
}

.price-card-label {
    font-size: .75rem;
    color: var(--text-muted);
    margin-bottom: .125rem;
}

.price-card-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .5rem;
    padding-top: .5rem;
    border-top: 1px solid var(--border-color);
}

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

.price-stat-key {
    font-size: .6875rem;
    color: var(--text-muted);
    font-weight: 500;
    display: block;
    margin-bottom: .125rem;
}

.price-stat-val {
    font-size: .875rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-mono);
}

.price-card-time {
    font-size: .6875rem;
    color: var(--text-muted);
    text-align: right;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .25rem;
}

.price-live-dot {
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
    display: inline-block;
    animation: livePulse 2s infinite;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .4; }
}

/* Small type tabs inside calculator */
.type-tabs-sm {
    padding: 2px;
}
.type-tabs-sm .type-tab {
    padding: .3rem .625rem;
    font-size: .75rem;
}

/* --- Forms --- */
.form-group {
    display: flex;
    flex-direction: column;
    gap: .375rem;
}

.form-label {
    font-size: .8125rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-input, .form-select {
    width: 100%;
    padding: .625rem .75rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: .875rem;
    transition: var(--transition);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: inherit;
}

.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .1);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* --- Buttons --- */
.btn {
    padding: .5rem 1rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: .8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .375rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-secondary);
}

.btn:disabled {
    opacity: .45;
    cursor: not-allowed;
    transform: none !important;
}

.btn-row {
    display: flex;
    gap: .5rem;
    margin-top: .75rem;
}

/* --- Result Panel --- */
.result-panel {
    margin-top: 1.25rem;
    padding: 1.25rem;
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    display: none;
    animation: fadeSlideIn .25s ease-out;
}

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

.result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.result-item {
    text-align: center;
    padding: .875rem;
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
}

.result-item-label {
    font-size: .75rem;
    color: var(--text-muted);
    margin-bottom: .25rem;
    font-weight: 500;
}

.result-item-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    font-family: var(--font-mono);
}

.result-total {
    text-align: center;
    padding: 1rem;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 1.125rem;
    font-family: var(--font-mono);
}

.result-total.positive {
    background: #dcfce7;
    color: #16a34a;
}

.result-total.negative {
    background: #fee2e2;
    color: #dc2626;
}

.result-total.neutral {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

/* --- Alert Subscribe --- */
.alert-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.alert-status {
    margin-top: .75rem;
    padding: .5rem .75rem;
    border-radius: var(--radius-md);
    font-size: .8125rem;
    text-align: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

/* --- Chart --- */
.chart-container {
    width: 100%;
    height: 320px;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
}

.chart-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 2px dashed var(--border-color);
    color: var(--text-muted);
}

.chart-placeholder-icon { font-size: 2.5rem; margin-bottom: .75rem; opacity: .5; }
.chart-placeholder-text { font-size: 1rem; font-weight: 600; }
.chart-placeholder-sub { font-size: .8rem; margin-top: .25rem; }

.chart-info {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    margin-top: 1rem;
    padding: .75rem 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--info);
}

.chart-info-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .8rem;
    color: var(--text-secondary);
}

/* --- Stats Grid --- */
.stats-section { margin-top: 1.5rem; }

.stats-title {
    font-size: .9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.stat-card {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    text-align: center;
    transition: var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.stat-label {
    font-size: .75rem;
    color: var(--text-muted);
    margin-bottom: .375rem;
    font-weight: 500;
}

.stat-value {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--primary);
    font-family: var(--font-mono);
    margin-bottom: .25rem;
}

.stat-tag {
    display: inline-block;
    font-size: .6875rem;
    font-weight: 600;
    padding: .125rem .5rem;
    border-radius: 10px;
}

.stat-tag.up { background: #dcfce7; color: #16a34a; }
.stat-tag.down { background: #fee2e2; color: #dc2626; }
.stat-tag.neutral { background: var(--bg-tertiary); color: var(--text-muted); }

/* --- Range Tabs --- */
.range-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-tertiary);
    padding: 3px;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    width: fit-content;
}

.range-tab {
    background: none;
    border: none;
    padding: .4rem .75rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: .8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: var(--transition);
    font-family: inherit;
}

.range-tab.active {
    background: var(--bg-primary);
    color: var(--primary);
    box-shadow: var(--shadow-xs);
}

.range-tab:hover:not(.active) {
    color: var(--text-primary);
}

.range-tabs-sm {
    padding: 2px;
    gap: 2px;
}

.range-tabs-sm .range-tab {
    padding: .3rem .5rem;
    font-size: .75rem;
}

/* --- Larger Chart Container --- */
.chart-container-lg {
    height: 420px;
}

/* --- Price Levels Legend --- */
.price-levels-legend {
    display: flex;
    gap: 1.25rem;
    padding: .75rem 0;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: .375rem;
    font-size: .75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.legend-dot-high { background: #ef4444; }
.legend-dot-low { background: #22c55e; }

.legend-line {
    width: 16px;
    height: 0;
    border-top: 2px dashed #94a3b8;
    display: inline-block;
}

.legend-line-round {
    border-top-color: #94a3b8;
}

/* --- 4-col Stats Grid --- */
.stats-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* --- Text color utilities --- */
.text-up { color: #ef4444 !important; }
.text-down { color: #22c55e !important; }

/* --- Footer --- */
.site-footer {
    text-align: center;
    padding: 1.25rem;
    font-size: .75rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

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

/* --- Responsive --- */
@media (max-width: 768px) {
    .content { padding: 1rem; gap: 1rem; }
    .grid-2 { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr; gap: .75rem; }
    .stats-grid-4 { grid-template-columns: repeat(2, 1fr); }
    .chart-container-lg { height: 320px; }
    .card { padding: 1.25rem; }
    .price-value { font-size: 2.25rem; }
    .chart-container { height: 260px; }

    .nav-toggle { display: flex; }
    .nav-links {
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        background: var(--bg-primary);
        flex-direction: column;
        padding: .5rem;
        border-bottom: 1px solid var(--border-color);
        box-shadow: var(--shadow-md);
        transform: translateY(-10px);
        opacity: 0;
        visibility: hidden;
        transition: var(--transition);
    }
    .nav-links.open {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }
    .nav-link { padding: .75rem 1rem; }
}

@media (max-width: 480px) {
    .content { padding: .75rem; }
    .card { padding: 1rem; }
    .price-value { font-size: 2rem; }
    .result-grid { grid-template-columns: 1fr; }
    .chart-container { height: 220px; }
    .chart-container-lg { height: 280px; }
    .stats-grid-4 { grid-template-columns: repeat(2, 1fr); }
    .range-tabs { flex-wrap: wrap; }
}
