/*  Metalytics – Crypto Dashboard
    Main stylesheet - dark theme default with light mode toggle */

/* reset */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* color scheme - dark mode (default) */
:root {
    --bg-body: #0b0f19;
    --bg-card: #1a2235;
    --bg-input: #151d2e;
    --bg-surface: #111827;
    --text-primary: #e8ecf4;
    --text-secondary: #7b8ba5;
    --text-muted: #4a5568;
    --border-color: #1e2a3e;
    --border-hover: #2d3f5a;
    --accent-1: #f7b731;
    --accent-gradient: linear-gradient(135deg, #f7b731, #fc5c65);
    --green: #2ecc71;
    --green-bg: rgba(46, 204, 113, 0.12);
    --red: #e74c3c;
    --red-bg: rgba(231, 76, 60, 0.12);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px rgba(247, 183, 49, 0.08);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --radius-sm: 8px;
    --radius-md: 12px;
}

/* light mode overrides */
[data-theme="light"] {
    --bg-body: #f0f2f5;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --bg-surface: #e4e7ec;
    --text-primary: #1a202c;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-glow: 0 0 20px rgba(247, 183, 49, 0.05);
}

body {
    font-family: var(--font);
    background: var(--bg-body);
    color: var(--text-primary);
    padding: 0 24px 40px;
    max-width: 1200px;
    margin: 0 auto;
    min-height: 100vh;
    transition: background 0.25s, color 0.25s;
    -webkit-font-smoothing: antialiased;
}

/* header layout */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0 16px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-body);
}

.header-left { display: flex; align-items: center; gap: 14px; }

.logo-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: 800;
    color: #fff;
    box-shadow: 0 2px 12px rgba(247, 183, 49, 0.3);
    animation: logo-pulse 3s ease-in-out infinite;
}

@keyframes logo-pulse {
    0%, 100% { box-shadow: 0 2px 12px rgba(247, 183, 49, 0.3); }
    50% { box-shadow: 0 2px 24px rgba(247, 183, 49, 0.5); }
}

header h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline { color: var(--text-secondary); font-size: 0.78rem; font-weight: 500; }
.header-right { display: flex; align-items: center; gap: 12px; }
.last-updated { font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; }

#theme-toggle {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
#theme-toggle:hover { border-color: var(--border-hover); transform: scale(1.05); }

/* controls bar (search + dropdowns) */
.controls { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }

.controls input,
.controls select {
    padding: 11px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.15s;
}

.controls input { flex: 1; min-width: 220px; }
.controls input::placeholder { color: var(--text-muted); }

.controls input:focus, .controls select:focus {
    border-color: var(--accent-1);
    box-shadow: 0 0 0 3px rgba(247, 183, 49, 0.1);
}

.controls select {
    cursor: pointer;
    appearance: none;
    padding-right: 32px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237b8ba5' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

/* stats chips row */
.stats-bar { display: flex; gap: 10px; margin-bottom: 24px; flex-wrap: wrap; }

.stat-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 16px;
}

.stat-label { font-size: 0.72rem; color: var(--text-secondary); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 0.95rem; font-weight: 700; color: var(--text-primary); }
.stat-value.green { color: var(--green); }

/* loading spinner */
.loader { display: none; text-align: center; padding: 80px 20px; color: var(--text-secondary); }
.loader.active { display: block; }
.loader p { font-size: 0.88rem; font-weight: 500; }

.spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--accent-1);
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* error banner */
.error-msg {
    text-align: center; padding: 24px; margin-bottom: 20px;
    background: var(--red-bg); border: 1px solid rgba(231, 76, 60, 0.2);
    border-radius: var(--radius-md); color: var(--red); font-size: 0.88rem; font-weight: 500;
}

/* cards grid */
.cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    margin-bottom: 40px;
}

/* individual card */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: all 0.25s;
    position: relative;
    overflow: hidden;
}

/* gold accent line on top of card (visible on hover) */
.card::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity 0.25s;
}

.card:hover {
    transform: translateY(-4px);
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md), var(--shadow-glow);
}
.card:hover::before { opacity: 1; }

.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-info { display: flex; align-items: center; gap: 10px; }
.card-rank { font-size: 0.68rem; font-weight: 700; color: var(--text-muted); min-width: 28px; }

.card-icon {
    width: 36px; height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-surface);
}

.card-name { font-weight: 600; font-size: 0.95rem; line-height: 1.2; }
.card-symbol { color: var(--text-secondary); font-size: 0.72rem; font-weight: 500; margin-top: 1px; }

/* fav star button */
.favorite-btn {
    background: none; border: none; font-size: 1.3rem;
    cursor: pointer; padding: 4px; line-height: 1;
    transition: transform 0.15s; filter: grayscale(0.3);
}
.favorite-btn:hover { transform: scale(1.25); filter: grayscale(0); }
.favorite-btn.is-fav { filter: none; animation: pop 0.3s ease; }

@keyframes pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.4); }
    100% { transform: scale(1); }
}

.card-price { font-size: 1.45rem; font-weight: 800; margin-bottom: 6px; letter-spacing: -0.5px; }

/* green/red change badge */
.card-change { font-size: 0.88rem; font-weight: 600; padding: 3px 10px; border-radius: 6px; display: inline-block; margin-bottom: 4px; }
.card-change.positive { color: var(--green); background: var(--green-bg); }
.card-change.negative { color: var(--red); background: var(--red-bg); }

.card-footer {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border-color);
}
.card-footer-label { font-size: 0.74rem; color: var(--text-secondary); font-weight: 500; }

/* empty state */
.no-results { text-align: center; padding: 60px 20px; color: var(--text-secondary); grid-column: 1 / -1; font-size: 0.95rem; }
.no-results .no-results-icon { font-size: 2.5rem; margin-bottom: 12px; display: block; }

/* view all / back / load more buttons */
.view-toggle {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 8px 0 32px;
    flex-wrap: wrap;
}

.view-all-btn, .load-more-btn {
    padding: 14px 36px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--accent-gradient);
    color: #fff;
    font-family: var(--font);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 12px rgba(247, 183, 49, 0.2);
}
.view-all-btn:hover, .load-more-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(247, 183, 49, 0.35);
}

.back-btn {
    padding: 14px 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.back-btn:hover { border-color: var(--accent-1); color: var(--accent-1); }

/* footer */
footer { text-align: center; padding: 20px 0; border-top: 1px solid var(--border-color); color: var(--text-muted); font-size: 0.78rem; }
footer a { color: var(--accent-1); text-decoration: none; font-weight: 500; }
footer a:hover { text-decoration: underline; }

/* tablet */
@media (max-width: 768px) {
    body { padding: 0 16px 32px; }
    header h1 { font-size: 1.25rem; }
    .tagline { display: none; }
    .controls { flex-direction: column; }
    .controls input { min-width: 100%; }
    .stat-chip { flex: 1; min-width: calc(50% - 5px); justify-content: center; }
    .cards-container { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
}

/* mobile */
@media (max-width: 480px) {
    body { padding: 0 12px 24px; }
    .logo-icon { width: 36px; height: 36px; font-size: 1.1rem; }
    .cards-container { grid-template-columns: 1fr; }
    .card-price { font-size: 1.2rem; }
    .stat-chip { min-width: calc(50% - 5px); }
    .last-updated { display: none; }
}
