/* ============== VARIÁVEIS ============== */
:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --border-color: #30363d;
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent-green: #2ea043;
    --accent-green-light: #3fb950;
    --accent-red: #f85149;
    --accent-red-light: #ff7b72;
    --accent-blue: #58a6ff;
    --accent-yellow: #d29922;
    --accent-purple: #a371f7;
}

/* ============== RESET & BASE ============== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

/* ============== LAYOUT ============== */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

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

.main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar pode ser opcional; o chart-section já usa flex: 1 */

/* ============== HEADER ============== */
.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 28px;
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-info {
    display: flex;
    gap: 24px;
    align-items: center;
}

.server-time, .connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent-red);
    animation: pulse 2s infinite;
}

.connection-status.connected .status-dot {
    background: var(--accent-green);
}

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

.account-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-admin-drawer {
    display: none;
}

/* ============== SIDEBAR ============== */
.sidebar {
    width: 200px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 16px;
    overflow-y: auto;
}

.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.drawer-close {
    display: none;
    appearance: none;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    width: 34px;
    height: 34px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.drawer-close:hover {
    background: var(--bg-primary);
}

.sidebar h3 {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.asset-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.asset-toolbar {
    margin-bottom: 10px;
    display: flex;
    gap: 8px;
}

.btn-all-assets {
    width: 100%;
    padding: 8px 10px;
    font-size: 12px;
}

.asset-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.asset-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.asset-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(48, 54, 61, 0.8);
    object-fit: cover;
    flex: 0 0 auto;
}

.asset-titles {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

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

.asset-item.active {
    border-color: var(--accent-blue);
    background: rgba(88, 166, 255, 0.1);
}

.asset-item .name {
    font-weight: 500;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.asset-item .sub {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.asset-item .price {
    font-size: 12px;
    color: var(--text-secondary);
}

.admin-panel {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.sidebar-admin-only .admin-panel {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.admin-panel h4 {
    font-size: 12px;
    color: var(--accent-yellow);
    margin-bottom: 10px;
}

.admin-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.btn-admin {
    padding: 6px 10px;
    font-size: 11px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-admin:hover {
    background: var(--accent-purple);
    color: white;
    border-color: var(--accent-purple);
}

/* ============== CHART SECTION ============== */
.chart-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px;
    overflow: hidden;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.asset-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.asset-info-clickable {
    cursor: pointer;
    user-select: none;
}

.asset-info-clickable:hover .current-asset {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.asset-head-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(48, 54, 61, 0.8);
    object-fit: cover;
}

.candle-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.candle-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.current-asset {
    font-size: 16px;
    font-weight: 700;
}

.chart-controls select {
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 4px;
    cursor: pointer;
}

.chart-container {
    flex: 1;
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

/* Mini card do ativo (overlay no gráfico) */
.chart-asset-card {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(48, 54, 61, 0.9);
    background: rgba(13, 17, 23, 0.92);
    backdrop-filter: blur(6px);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
    cursor: pointer;
    user-select: none;
    transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.chart-asset-card:hover {
    border-color: rgba(88, 166, 255, 0.85);
    transform: translateY(-1px);
}

.chart-asset-card:focus {
    outline: none;
    border-color: rgba(88, 166, 255, 0.95);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.18), 0 10px 26px rgba(0, 0, 0, 0.35);
}

.chart-asset-icon {
    width: 28px;
    height: 28px;
    object-fit: cover;
}

.chart-asset-text { display: flex; flex-direction: column; line-height: 1.1; }
.chart-asset-name { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.chart-asset-sub { font-size: 12px; color: var(--text-secondary); }
.chart-asset-hint { font-size: 11px; color: var(--text-muted); opacity: 0.0; transform: translateY(-2px); transition: opacity 0.15s ease, transform 0.15s ease; }
.chart-asset-card:hover .chart-asset-hint { opacity: 1; transform: translateY(0); }

/* ============== BUTTONS ============== */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

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

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

/* ============== TOAST ============== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 14px 20px;
    border-radius: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.success {
    border-color: var(--accent-green);
    background: rgba(46, 160, 67, 0.1);
}

.toast.error {
    border-color: var(--accent-red);
    background: rgba(248, 81, 73, 0.1);
}

.toast.info {
    border-color: var(--accent-blue);
    background: rgba(88, 166, 255, 0.1);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

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

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

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

::-webkit-scrollbar-thumb:hover {
    background: var(--border-color);
}

/* ============== EMPTY STATE ============== */
.empty-state {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 13px;
}

/* ============== MODAL ============== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.modal {
    width: min(720px, 100%);
    max-height: min(720px, 90vh);
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 14px 0 14px;
    gap: 12px;
}

.modal-title {
    font-size: 14px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: 0.2px;
}

.modal-close {
    padding: 6px 10px;
    font-size: 12px;
}

.modal-search {
    margin: 0 14px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    outline: none;
}

.modal-search:focus {
    border-color: rgba(88, 166, 255, 0.8);
}

.modal-list {
    padding: 0 14px 14px 14px;
    overflow: auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

@media (max-width: 640px) {
    .modal-list { grid-template-columns: 1fr; }
}

.modal-asset-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    min-width: 0;
}

.modal-asset-item:hover {
    background: var(--bg-primary);
}

.modal-asset-item.active {
    border-color: var(--accent-blue);
    background: rgba(88, 166, 255, 0.1);
}

.modal-asset-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    margin-left: 10px;
}

.modal-asset-symbol {
    font-size: 11px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* Ações do card (símbolo + lixeira) */
.modal-asset-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 10px;
    flex: 0 0 auto;
}

.modal-asset-delete {
    appearance: none;
    border: 1px solid rgba(48, 54, 61, 0.9);
    background: rgba(13, 17, 23, 0.35);
    color: var(--text-muted);
    width: 30px;
    height: 30px;
    border-radius: 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.modal-asset-delete:hover {
    border-color: rgba(248, 81, 73, 0.9);
    color: var(--accent-red-light);
    background: rgba(248, 81, 73, 0.10);
    transform: translateY(-1px);
}

.modal-asset-delete:active {
    transform: translateY(0);
}

.modal-asset-delete:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(248, 81, 73, 0.20);
}

/* ============== RESPONSIVO / DRAWER ADMIN ============== */
.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(3px);
    z-index: 1500;
}

@media (max-width: 900px) {
    .sidebar { width: 180px; padding: 14px; }
    .chart-section { padding: 12px; }
    .header { padding: 10px 16px; }
    .header-info { gap: 16px; }
}

@media (max-width: 720px) {
    body { overflow: hidden; }
    .logo-text { display: none; }
    .header-info { display: none; }
    .account-info { gap: 10px; }
    .btn-admin-drawer { display: inline-flex; align-items: center; gap: 8px; }

    /* Sidebar vira drawer (fora do fluxo) */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        max-height: 100dvh;
        width: min(320px, 86vw);
        z-index: 1600;
        transform: translateX(-110%);
        transition: transform 0.18s ease;
        box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
    }

    body.admin-open .sidebar {
        transform: translateX(0);
    }

    body.admin-open #adminSidebarOverlay {
        display: block !important;
    }

    .drawer-close { display: inline-flex; align-items: center; justify-content: center; }

    /* Chart usa toda a largura */
    .chart-section { padding: 10px; }
    .chart-container { border-radius: 10px; }
    .chart-header { flex-wrap: wrap; gap: 10px; }
}
