/* ============================================
   NexoZones — Dark Professional Theme
   ============================================ */

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-hover: #30363d;
    --border: #30363d;
    --border-light: #484f58;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent: #58a6ff;
    --accent-hover: #79c0ff;
    --green: #3fb950;
    --green-bg: rgba(63, 185, 80, 0.15);
    --red: #f85149;
    --red-bg: rgba(248, 81, 73, 0.15);
    --yellow: #d29922;
    --yellow-bg: rgba(210, 153, 34, 0.15);
    --orange: #db6d28;
    --purple: #bc8cff;
    --chart-green: #26a69a;
    --chart-red: #ef5350;
    --zone-support: rgba(63, 185, 80, 0.15);
    --zone-support-border: rgba(63, 185, 80, 0.4);
    --zone-resistance: rgba(248, 81, 73, 0.15);
    --zone-resistance-border: rgba(248, 81, 73, 0.4);
    --sidebar-width: 320px;
    --header-height: 70px;
    --radius: 8px;
    --radius-sm: 4px;
    --transition: 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---- Modal ---- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
}

.modal-overlay.hidden { display: none; }

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px;
    max-width: 520px;
    width: 90%;
    text-align: center;
}

.modal h2 {
    font-size: 1.3rem;
    margin-bottom: 16px;
    color: var(--yellow);
}

.modal p {
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-size: 0.95rem;
    line-height: 1.6;
}

.modal p strong { color: var(--text-primary); }

/* ---- Buttons ---- */
.btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn:hover { background: var(--bg-hover); border-color: var(--border-light); }

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

.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-ghost {
    background: transparent;
    border-color: transparent;
    font-size: 1.2rem;
    padding: 6px 10px;
}

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

/* ---- Header ---- */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 16px;
    flex-wrap: wrap;
}

.header-left { flex-shrink: 0; }

.logo {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo span {
    background: linear-gradient(135deg, var(--accent), var(--purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-center {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.symbol-input {
    display: flex;
    gap: 8px;
    align-items: center;
}

.symbol-input input {
    width: 140px;
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.symbol-input input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

.timeframe-buttons {
    display: flex;
    gap: 4px;
}

.tf-btn {
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all var(--transition);
}

.tf-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.tf-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.tf-multi {
    color: var(--purple);
    border-color: rgba(188, 140, 255, 0.3);
}

.tf-multi.active {
    background: var(--purple);
    border-color: var(--purple);
    color: #fff;
}

.header-right { flex-shrink: 0; }

/* ---- Loading ---- */
.loading {
    position: fixed;
    top: var(--header-height);
    left: 0; right: 0;
    bottom: 0;
    background: rgba(13, 17, 23, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
    backdrop-filter: blur(2px);
}

.loading.hidden { display: none; }

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading p {
    margin-top: 12px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ---- Error ---- */
.error-message {
    position: fixed;
    top: calc(var(--header-height) + 12px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--red-bg);
    border: 1px solid rgba(248, 81, 73, 0.3);
    border-radius: var(--radius);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 200;
    max-width: 500px;
}

.error-message.hidden { display: none; }

.error-icon { font-size: 1.1rem; }

.error-text {
    color: var(--red);
    font-size: 0.875rem;
}

.error-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    margin-left: 8px;
}

/* ---- Main Layout ---- */
.main-content {
    display: flex;
    gap: 0;
    min-height: calc(100vh - var(--header-height) - 200px);
}

.chart-container {
    flex: 1;
    min-width: 0;
    padding: 12px;
    position: relative;
}

#chart {
    width: 100%;
    height: 500px;
    border-radius: var(--radius);
    overflow: hidden;
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    padding: 12px;
    border-left: 1px solid var(--border);
    overflow-y: auto;
    max-height: calc(100vh - var(--header-height));
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
}

.panel h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 10px;
    font-weight: 600;
}

/* Price Panel */
.price-value {
    font-size: 1.8rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

.price-symbol {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Trend Panel */
.trend-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
}

.trend-item:last-child { border-bottom: none; }

.tf-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}

.trend-value {
    font-size: 0.85rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
}

.trend-alta-forte { color: var(--green); background: var(--green-bg); }
.trend-alta-moderada { color: var(--green); background: var(--green-bg); opacity: 0.8; }
.trend-lateral { color: var(--yellow); background: var(--yellow-bg); }
.trend-baixa-moderada { color: var(--red); background: var(--red-bg); opacity: 0.8; }
.trend-baixa-forte { color: var(--red); background: var(--red-bg); }
.trend-indeterminado { color: var(--text-muted); }

/* Zone Info */
.zone-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.zone-price {
    font-size: 1.1rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.zone-strength {
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.strength-crítica { color: var(--red); background: var(--red-bg); }
.strength-forte { color: var(--orange); background: rgba(219, 109, 40, 0.15); }
.strength-moderada { color: var(--yellow); background: var(--yellow-bg); }
.strength-fraca { color: var(--text-muted); background: var(--bg-tertiary); }

.zone-detail {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Alerts */
.alert-item {
    padding: 8px;
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    font-size: 0.8rem;
    border: 1px solid;
}

.alert-critical { background: var(--red-bg); border-color: rgba(248, 81, 73, 0.3); color: var(--red); }
.alert-high { background: rgba(219, 109, 40, 0.1); border-color: rgba(219, 109, 40, 0.3); color: var(--orange); }
.alert-medium { background: var(--yellow-bg); border-color: rgba(210, 153, 34, 0.3); color: var(--yellow); }
.alert-low { background: var(--bg-tertiary); border-color: var(--border); color: var(--text-secondary); }

.no-alerts, .no-watchlist {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-style: italic;
}

/* Watchlist */
.watchlist-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--transition);
}

.watchlist-item:hover { background: var(--bg-hover); }

.watchlist-item:last-child { border-bottom: none; }

.wl-symbol {
    font-weight: 600;
    font-size: 0.85rem;
}

.wl-price {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.wl-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 2px 6px;
}

.wl-remove:hover { color: var(--red); }

/* ---- Zones Table ---- */
.zones-table-section {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

.zones-table-section h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.table-controls {
    margin-bottom: 12px;
}

.table-controls label {
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

.table-controls input[type="checkbox"] {
    accent-color: var(--accent);
}

.table-wrapper {
    overflow-x: auto;
}

#zones-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

#zones-table th {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-size: 0.75rem;
    white-space: nowrap;
}

#zones-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    font-variant-numeric: tabular-nums;
}

#zones-table tr:hover { background: var(--bg-hover); }

.empty-row {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    padding: 24px !important;
}

.type-support { color: var(--green); font-weight: 600; }
.type-resistance { color: var(--red); font-weight: 600; }

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

.footer p {
    font-size: 0.75rem;
    color: var(--text-muted);
    max-width: 700px;
    margin: 0 auto 8px;
    line-height: 1.6;
}

.footer-copy {
    font-size: 0.7rem;
    color: var(--text-muted);
    opacity: 0.6;
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
    .main-content {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border);
        max-height: none;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .panel { flex: 1; min-width: 250px; }
    #chart { height: 400px; }
}

@media (max-width: 768px) {
    .header {
        height: auto;
        padding: 10px;
        flex-direction: column;
        gap: 8px;
    }

    .header-center {
        flex-direction: column;
        width: 100%;
    }

    .symbol-input { width: 100%; }
    .symbol-input input { flex: 1; }

    .timeframe-buttons { flex-wrap: wrap; justify-content: center; }

    #chart { height: 350px; }

    .sidebar { flex-direction: column; }
    .panel { min-width: auto; }

    .price-value { font-size: 1.4rem; }
}

@media (max-width: 480px) {
    .tf-btn { padding: 5px 8px; font-size: 0.75rem; }
    #chart { height: 300px; }
}
