/* UI Premium Styles - BetaBot TV */

:root {
    --glass-bg: rgba(20, 20, 20, 0.7);
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
    --accent-color: #00d4ff;
    --text-primary: #ffffff;
    --text-secondary: #aaaaaa;
    --danger-color: #ff4d4d;
    --success-color: #00cc88;
    --fade-opacity: 0.15;
    --fade-transition: 0.5s;
}

/* ========================================
   AUTO-FADE: Elementos ficam transparentes após inatividade
   ======================================== */
.auto-fade {
    transition: opacity var(--fade-transition) ease;
}

.auto-fade.faded {
    opacity: var(--fade-opacity);
    pointer-events: none;
    /* Não bloqueia cliques quando transparente */
}

.auto-fade:hover,
.auto-fade.active,
.auto-fade:focus-within {
    opacity: 1 !important;
    pointer-events: auto;
}

/* Container da Hotlist */
.betabot-hotlist {
    position: fixed;
    z-index: 50;
    /* Acima do gráfico */
    display: flex;
    gap: 10px;
    padding: 10px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    border: var(--glass-border);
    transition: all 0.3s ease;
}

/* Posição Desktop: Lateral Direita Vertical */
@media (min-width: 769px) {
    .betabot-hotlist {
        top: 50%;
        right: 20px;
        transform: translateY(-50%);
        flex-direction: column;
        width: 60px;
    }
}

/* Posição Mobile: Barra Superior Horizontal */
@media (max-width: 768px) {
    .betabot-hotlist {
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        flex-direction: row;
        width: 90%;
        max-width: 400px;
        overflow-x: auto;
        justify-content: space-between;
        padding: 8px 15px;
    }

    /* Hide scrollbar */
    .betabot-hotlist::-webkit-scrollbar {
        display: none;
    }
}

/* Item da Moeda */
.hotlist-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 5px;
    border-radius: 8px;
    transition: background 0.2s;
    position: relative;
}

.hotlist-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.hotlist-item.active {
    background: rgba(0, 212, 255, 0.15);
    border: 1px solid rgba(0, 212, 255, 0.3);
}

.coin-icon {
    width: 24px;
    height: 24px;
    margin-bottom: 2px;
    border-radius: 50%;
    background-color: #333;
    /* Fallback */
}

.coin-symbol {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    font-family: 'Segoe UI', sans-serif;
}

.hotlist-item.active .coin-symbol {
    color: var(--accent-color);
}

/* Badge de Variação (Opcional - Futuro) */
.coin-change {
    font-size: 8px;
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--success-color);
    color: #000;
    padding: 1px 3px;
    border-radius: 4px;
    display: none;
    /* Hidden for now */
}

/* Título bonito da Hotlist (Só Desktop) */
.hotlist-header {
    font-size: 9px;
    text-transform: uppercase;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 5px;
    letter-spacing: 1px;
}

@media (max-width: 768px) {
    .hotlist-header {
        display: none;
    }
}

/* ========================================
   PAINEL DE RESUMO FLUTUANTE
   ======================================== */
.betabot-summary-panel {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 100;
    /* Reduced from 9999 to not overlap TradingView toolbar */
}

/* Botão Toggle (ícone quando fechado) */
.summary-toggle-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: var(--glass-border);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    transition: all 0.3s ease;
}

.summary-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(0, 212, 255, 0.3);
}

.summary-toggle-btn img {
    width: 28px;
    height: 28px;
}

/* Conteúdo do Painel */
.summary-content {
    position: relative;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    padding: 15px 20px;
    border: var(--glass-border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    min-width: 180px;
    font-family: 'Segoe UI', -apple-system, sans-serif;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Botão Fechar (X) */
.summary-close-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.summary-close-btn:hover {
    background: rgba(255, 77, 77, 0.3);
    color: #ff4d4d;
}

@media (max-width: 768px) {
    .betabot-summary-panel {
        top: 10px;
        right: 10px;
    }

    .summary-toggle-btn {
        width: 40px;
        height: 40px;
    }

    .summary-toggle-btn img {
        width: 24px;
        height: 24px;
    }

    .summary-content {
        min-width: 160px;
        padding: 12px 15px;
        font-size: 11px;
    }

    .summary-pair {
        font-size: 14px;
    }

    .summary-logo {
        width: 18px;
        height: 18px;
    }
}

.summary-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.summary-logo {
    width: 24px;
    height: 24px;
}

.summary-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
}

.summary-pair {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.summary-row:last-child {
    border-bottom: none;
}

.summary-label {
    font-size: 11px;
    color: var(--text-secondary);
}

.summary-value {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.summary-value.bullish {
    color: var(--success-color);
}

.summary-value.bearish {
    color: var(--danger-color);
}

/* ========================================
   COUNTDOWN TIMER
   ======================================== */
.betabot-countdown {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 100;
    /* Reduced from 9999 to not overlap TradingView toolbar */
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 10px 15px;
    border: var(--glass-border);
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Segoe UI', monospace;
}

@media (max-width: 768px) {
    .betabot-countdown {
        bottom: 80px;
        left: 10px;
        padding: 8px 12px;
    }
}

.countdown-label {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.countdown-time {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent-color);
    font-variant-numeric: tabular-nums;
}

/* ========================================
   BOTÃO DE TEMA NO HEADER DO TRADINGVIEW
   ======================================== */
.header-theme-btn {
    position: fixed;
    top: 6px;
    right: 180px;
    /* Posicionado próximo aos outros botões do header */
    z-index: 200;
    /* Reduced to be below TradingView but above custom UI */
    width: 32px;
    height: 32px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    transition: all 0.2s;
}

.header-theme-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.header-theme-btn svg {
    width: 18px;
    height: 18px;
    fill: #787b86;
    transition: fill 0.2s;
}

.header-theme-btn:hover svg {
    fill: #ffffff;
}

/* Mobile: posicionar no canto direito */
@media (max-width: 768px) {
    .header-theme-btn {
        top: 8px;
        right: 10px;
        width: 36px;
        height: 36px;
        background: rgba(0, 0, 0, 0.3);
        border-radius: 50%;
    }

    .header-theme-btn svg {
        width: 20px;
        height: 20px;
    }
}

/* Tema Claro Override */
body.light-theme {
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: 1px solid rgba(0, 0, 0, 0.1);
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
}

body.light-theme .header-theme-btn svg {
    fill: #131722;
}

body.light-theme .header-theme-btn:hover svg {
    fill: #2962ff;
}

/* ========================================
   INDICADOR DE STATUS WEBSOCKET
   ======================================== */
.ws-status {
    position: fixed;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    border: var(--glass-border);
    font-size: 11px;
    font-family: 'Segoe UI', sans-serif;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #00cc88;
    animation: pulse 2s infinite;
}

.ws-status.connected .status-dot {
    background: #00cc88;
}

.ws-status.disconnected .status-dot {
    background: #ff4d4d;
    animation: none;
}

.ws-status.reconnecting .status-dot {
    background: #ffaa00;
    animation: blink 0.5s infinite;
}

.ws-status.error .status-dot {
    background: #ff4d4d;
    animation: none;
}

.status-text {
    color: var(--text-secondary);
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

@media (max-width: 768px) {
    .ws-status {
        top: 50px;
        font-size: 10px;
        padding: 3px 8px;
    }
}

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */
.toast-notification {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    z-index: 10000;
    padding: 12px 24px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border-radius: 8px;
    border: var(--glass-border);
    color: var(--text-primary);
    font-size: 13px;
    font-family: 'Segoe UI', sans-serif;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

.toast-notification.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast-notification.success {
    border-left: 3px solid #00cc88;
}

.toast-notification.error {
    border-left: 3px solid #ff4d4d;
}

.toast-notification.info {
    border-left: 3px solid #00d4ff;
}

/* ========================================
   BOTÃO DE SOM NO HEADER
   ======================================== */
.header-sound-btn {
    position: fixed;
    top: 6px;
    right: 220px;
    z-index: 200;
    /* Reduced from 9999 */
    width: 32px;
    height: 32px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    transition: all 0.2s;
}

.header-sound-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.header-sound-btn svg {
    width: 18px;
    height: 18px;
    fill: #787b86;
    transition: fill 0.2s;
}

.header-sound-btn:hover svg {
    fill: #ffffff;
}

@media (max-width: 768px) {
    .header-sound-btn {
        top: 50px;
        right: 60px;
        width: 36px;
        height: 36px;
        background: rgba(0, 0, 0, 0.3);
        border-radius: 50%;
    }
}

/* Tema claro para novos componentes */
body.light-theme .ws-status {
    background: rgba(255, 255, 255, 0.9);
}

body.light-theme .toast-notification {
    background: rgba(255, 255, 255, 0.95);
}

body.light-theme .header-sound-btn svg {
    fill: #131722;
}

body.light-theme .header-sound-btn:hover svg {
    fill: #2962ff;
}

/* ========================================
   MULTI-CHART LAYOUT SYSTEM
   ======================================== */
#multi-chart-wrapper {
    width: 100vw;
    height: 100vh;
    display: grid;
    gap: 2px;
    background: #131722;
}

/* Layout 1 gráfico */
#multi-chart-wrapper.chart-layout-1 {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
}

#multi-chart-wrapper.chart-layout-1 .chart-container:not(:first-child) {
    display: none;
}

/* Layout 2 gráficos */
#multi-chart-wrapper.chart-layout-2 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr;
}

#multi-chart-wrapper.chart-layout-2 .chart-container:nth-child(n+3) {
    display: none;
}

/* Layout 4 gráficos */
#multi-chart-wrapper.chart-layout-4 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

/* Container de cada gráfico */
.chart-container {
    position: relative;
    background: #131722;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.chart-container .tv-chart {
    flex: 1;
    width: 100%;
    height: 100%;
}

/* Header de cada gráfico (mini) */
.chart-header {
    display: none;
    /* Oculto por padrão em layout 1 */
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 28px;
    background: rgba(19, 23, 34, 0.9);
    backdrop-filter: blur(8px);
    z-index: 10;
    padding: 0 10px;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Mostrar header em layouts 2 e 4 */
#multi-chart-wrapper.chart-layout-2 .chart-header,
#multi-chart-wrapper.chart-layout-4 .chart-header {
    display: flex;
}

.chart-symbol {
    font-size: 12px;
    font-weight: 600;
    color: #d1d4dc;
    font-family: 'Segoe UI', sans-serif;
}

.chart-symbol-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.chart-symbol-btn:hover {
    opacity: 1;
}

/* Botão de Layout no Header - próximo aos botões do TradingView */
.header-layout-btn {
    position: fixed;
    top: 6px;
    right: 420px;
    /* Mais à esquerda, perto de Indicators */
    z-index: 200;
    /* Reduced from 9999 */
    height: 28px;
    padding: 0 10px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: transparent;
    transition: all 0.2s;
    font-family: 'Trebuchet MS', -apple-system, sans-serif;
    color: #787b86;
    font-size: 13px;
}

.header-layout-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #d1d4dc;
}

.header-layout-btn::before {
    content: '⊞';
    font-size: 14px;
}

.layout-count {
    font-weight: 600;
    color: inherit;
}

@media (max-width: 768px) {
    .header-layout-btn {
        top: 50px;
        right: 10px;
        height: 36px;
        padding: 0 12px;
        background: rgba(0, 0, 0, 0.5);
        border-radius: 18px;
        color: #d1d4dc;
    }
}

/* Mobile: Apenas 1 ou 2 gráficos (tela pequena) */
@media (max-width: 768px) {
    #multi-chart-wrapper.chart-layout-4 {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }

    #multi-chart-wrapper.chart-layout-4 .chart-container:nth-child(n+3) {
        display: none;
    }

    #multi-chart-wrapper.chart-layout-2 {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }
}

/* Tema claro para multi-chart */
body.light-theme #multi-chart-wrapper {
    background: #f0f3fa;
}

body.light-theme .chart-container {
    background: #ffffff;
}

body.light-theme .header-layout-btn {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1);
}

/* ========================================
   GARANTIR VISIBILIDADE DA TOOLBAR LATERAL DO TRADINGVIEW
   ======================================== */
.chart-container .tv-chart {
    position: relative;
    z-index: 1;
}

#multi-chart-wrapper .chart-container iframe {
    z-index: auto !important;
}

.betabot-summary-panel,
.betabot-countdown,
.betabot-hotlist {
    pointer-events: auto;
}

body.light-theme .layout-count {
    color: #2962ff;
}

/* ========================================
   BOTÕES DE AÇÃO (Screenshot, etc)
   ======================================== */
.betabot-actions {
    position: fixed;
    top: 6px;
    right: 260px;
    z-index: 200;
    display: flex;
    gap: 4px;
    align-items: center;
}

.action-btn {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    transition: all 0.2s;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.action-btn svg {
    width: 18px;
    height: 18px;
    fill: #787b86;
    transition: fill 0.2s;
}

.action-btn:hover svg {
    fill: #ffffff;
}

@media (max-width: 768px) {
    .betabot-actions {
        top: 50px;
        right: 110px;
    }
}

body.light-theme .action-btn:hover svg {
    fill: #2962ff;
}