/**
 * CryptoScreener - Main Stylesheet
 * Dark Theme Default
 */

/* CSS Variables */
:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-card: #1c2128;

    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;

    --accent-primary: #58a6ff;
    --accent-secondary: #388bfd;

    --positive: #3fb950;
    --negative: #f85149;
    --warning: #d29922;

    --border-color: #30363d;
    --border-radius: 8px;

    --shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);

    --header-height: 60px;
    --transition: 0.2s ease;
}

/* Light Theme */
[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f6f8fa;
    --bg-tertiary: #eaeef2;
    --bg-card: #ffffff;

    --text-primary: #24292f;
    --text-secondary: #57606a;
    --text-muted: #8c959f;

    --border-color: #d0d7de;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

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

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

/* Typography */
h1, h2, h3, h4 {
    font-weight: 600;
    line-height: 1.3;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.125rem; }

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

a:hover {
    color: var(--accent-secondary);
}

/* Layout */
.main {
    min-height: calc(100vh - var(--header-height) - 60px);
    padding: 1.5rem;
    max-width: 1600px;
    margin: 0 auto;
}

/* Header */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    height: var(--header-height);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header__container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 1.5rem;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.header__logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.logo-icon {
    font-size: 1.5rem;
}

.header__nav {
    display: flex;
    gap: 0.5rem;
}

.nav-link {
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    transition: all var(--transition);
}

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

.header__actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-name {
    color: var(--text-secondary);
    margin-right: 0.5rem;
}

.header__mobile-toggle {
    display: none;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: var(--accent-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-secondary);
    color: #fff;
}

.btn-outline {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover {
    background: var(--bg-tertiary);
    border-color: var(--text-secondary);
}

.btn-block {
    width: 100%;
}

.btn-icon {
    background: transparent;
    border: none;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity var(--transition);
    font-size: 1rem;
}

.btn-icon:hover, .btn-icon.active {
    opacity: 1;
}

/* Forms */
.input, .select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: border-color var(--transition);
}

.input:focus, .select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.375rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
}

.alert-error {
    background: rgba(248, 81, 73, 0.15);
    border: 1px solid var(--negative);
    color: var(--negative);
}

.alert-success {
    background: rgba(63, 185, 80, 0.15);
    border: 1px solid var(--positive);
    color: var(--positive);
}

/* Widget */
.widget {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.widget__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.widget__header h3 {
    font-size: 0.9375rem;
    font-weight: 600;
}

.widget__loading {
    font-size: 0.875rem;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.widget__body {
    padding: 0;
    max-height: 400px;
    overflow-y: auto;
}

/* Data Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th, .data-table td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    background: var(--bg-tertiary);
    position: sticky;
    top: 0;
}

.data-row {
    transition: background var(--transition);
}

.data-row:hover {
    background: var(--bg-tertiary);
}

.data-table .symbol {
    font-weight: 600;
    cursor: pointer;
    color: var(--accent-primary);
}

.data-table .symbol:hover {
    text-decoration: underline;
}

.data-table .price {
    font-family: 'SF Mono', Consolas, monospace;
}

.data-table .percent {
    font-weight: 600;
    font-family: 'SF Mono', Consolas, monospace;
}

.data-table .positive {
    color: var(--positive);
}

.data-table .negative {
    color: var(--negative);
}

.data-table .actions {
    text-align: right;
    width: 40px;
}

.data-table .loading, .data-table .empty {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

/* Screener Layout */
.screener__filters {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.screener__filters .filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.screener__filters label {
    color: var(--text-secondary);
    font-size: 0.875rem;
    white-space: nowrap;
}

.screener__filters .select, .screener__filters .input {
    width: auto;
    min-width: 100px;
}

.last-update {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-left: auto;
}

.screener__grid {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 1.5rem;
}

.screener__chart {
    min-height: 400px;
}

.screener__widgets {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Chart Container */
.chart-container {
    display: grid;
    gap: 0.5rem;
    min-height: 350px;
}

.chart-container.charts-1 {
    grid-template-columns: 1fr;
}

.chart-container.charts-2 {
    grid-template-columns: 1fr 1fr;
}

.chart-container.charts-4 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.tradingview-widget {
    background: var(--bg-tertiary);
    border-radius: 4px;
    min-height: 300px;
}

.chart-controls {
    display: flex;
    gap: 0.25rem;
}

.chart-controls .btn-icon {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
}

.chart-controls .btn-icon.active {
    background: var(--accent-primary);
    color: #fff;
    opacity: 1;
}

/* Auth Pages */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--header-height) - 120px);
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 2rem;
    width: 100%;
    max-width: 400px;
}

.auth-card h1 {
    margin-bottom: 1.5rem;
    text-align: center;
}

.auth-footer {
    margin-top: 1.5rem;
    text-align: center;
    color: var(--text-secondary);
}

/* Settings Page */
.settings-page {
    max-width: 600px;
    margin: 0 auto;
}

.settings-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 2rem;
}

.settings-card h1 {
    margin-bottom: 1.5rem;
}

/* Dashboard */
.dashboard__header {
    margin-bottom: 2rem;
}

.dashboard__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.dashboard__card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
}

.dashboard__card h3 {
    margin-bottom: 0.5rem;
}

.dashboard__card p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.dashboard__stats h2 {
    margin-bottom: 1rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

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

.stat-label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.stat-value.positive { color: var(--positive); }
.stat-value.negative { color: var(--negative); }

/* Footer */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 1rem;
    text-align: center;
}

.footer__container {
    max-width: 1600px;
    margin: 0 auto;
}

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

.footer__disclaimer {
    margin-top: 0.5rem;
}

/* Responsive */
@media (max-width: 1024px) {
    .screener__grid {
        grid-template-columns: 1fr;
    }

    .screener__widgets {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    html {
        font-size: 13px;
    }

    .header__nav {
        display: none;
        position: absolute;
        top: var(--header-height);
        left: 0;
        right: 0;
        background: var(--bg-secondary);
        flex-direction: column;
        padding: 1rem;
        border-bottom: 1px solid var(--border-color);
    }

    .header__nav.active {
        display: flex;
    }

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

    .header__mobile-toggle span {
        width: 20px;
        height: 2px;
        background: var(--text-primary);
        transition: all var(--transition);
    }

    .screener__filters {
        flex-direction: column;
        align-items: stretch;
    }

    .screener__filters .filter-group {
        width: 100%;
    }

    .screener__filters .select, .screener__filters .input {
        flex: 1;
    }

    .screener__widgets {
        grid-template-columns: 1fr;
    }

    .chart-container.charts-2, .chart-container.charts-4 {
        grid-template-columns: 1fr;
    }
}

/* Pause button state */
.btn.paused {
    background: var(--warning);
    border-color: var(--warning);
    color: #000;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
