/* ============================================
   DEL REY WEB - CSS LIMPO E ORGANIZADO
   ============================================ */

:root {
    --bg-primary: #0a0e27;
    --bg-secondary: #1a1f3a;
    --text-primary: #ffffff;
    --text-secondary: #b0b8c4;
    --primary-color: #3b82f6;
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --border-color: #2a2f36;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    padding-top: 90px; /* Reduzido para melhor preenchimento no Telegram Web App */
    overflow-x: hidden;
    /* Mobile-first: garantir que não tenha scroll horizontal */
    width: 100%;
    max-width: 100vw;
    margin: 0;
    padding-left: 0;
    padding-right: 0;
}

/* ============================================
   HEADER
   ============================================ */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 2000; /* Aumentado para garantir que fique acima de tudo */
    width: 100%;
    box-sizing: border-box;
    min-height: 80px; /* Altura mínima do header */
}

.header-content h1 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-lang, .btn-profile {
    background: var(--primary-color);
    border: none;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
}

/* ============================================
   CONTAINER E TELAS
   ============================================ */
.container {
    max-width: 100%;
    width: 100%;
    margin: 0 auto;
    padding: 0.5rem 1rem 1rem 1rem;
    /* Mobile-first: otimizado para celular */
    box-sizing: border-box;
    margin-top: 20px; /* Espaço reduzido para melhor preenchimento */
    position: relative;
    z-index: 1; /* Garantir que fique acima do background */
}

.screen {
    display: none;
}

.screen.active {
    display: block;
}

/* ============================================
   SELEÇÃO DE SISTEMA
   ============================================ */
.system-list, .market-list, .timeframe-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 2rem;
}

.system-btn, .market-btn, .timeframe-btn {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s;
    text-align: left;
}

.system-btn:hover, .market-btn:hover, .timeframe-btn:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.system-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.5rem;
}

.system-name, .market-name, .timeframe-name {
    display: block;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.market-desc, .timeframe-desc {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ============================================
   TELA DE ANÁLISE
   ============================================ */
.analysis-container {
    text-align: center;
    padding: 3rem 1rem;
}

.analysis-message {
    font-size: 1.125rem;
    color: var(--text-primary);
    margin-bottom: 2rem;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.analysis-progress {
    width: 100%;
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
}

.analysis-progress::after {
    content: '';
    display: block;
    width: 70%;
    height: 100%;
    background: var(--primary-color);
    animation: progress 2s infinite;
}

@keyframes progress {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(400%); }
}

/* ============================================
   TELA DE RESULTADO
   ============================================ */
.result-container {
    padding: 0.5rem 0.5rem;
}

.result-content {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid var(--border-color);
}

.result-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1rem;
    text-align: center;
}

.result-info {
    font-size: 1rem;
    margin-bottom: 1rem;
    text-align: center;
}

.result-entry {
    background: rgba(59, 130, 246, 0.1);
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    padding: 1rem;
    margin: 1rem 0;
}

.result-entry-label {
    color: var(--primary-color);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.result-entry-time {
    font-size: 1.25rem;
    font-weight: 700;
}

.result-chart {
    margin: 1.5rem 0;
    text-align: center;
}

.result-chart img {
    max-width: 100%;
    border-radius: 12px;
    border: 2px solid var(--border-color);
}

.result-broker {
    margin-top: 1.5rem;
    text-align: center;
}

.btn-broker {
    display: inline-block;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 600;
    transition: transform 0.3s;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-broker:hover {
    transform: translateY(-2px);
}

.result-martingale {
    margin-top: 1rem;
    font-style: italic;
    color: var(--text-secondary);
    text-align: center;
}

/* ============================================
   SEM OPORTUNIDADE
   ============================================ */
.no-opportunity-container {
    text-align: center;
    padding: 3rem 1rem;
}

.no-opportunity-container h2 {
    margin-bottom: 1rem;
}

.no-opportunity-container p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.3s;
}

.btn-primary:hover {
    transform: translateY(-2px);
}

/* ============================================
   RESPONSIVO
   ============================================ */
/* Mobile-first: ajustes para telas pequenas - 100% mobile */
@media (max-width: 768px) {
    body {
        padding-top: 90px; /* Reduzido para melhor preenchimento no Telegram Web App */
    }
    
    .header {
        padding: 0.5rem 0.75rem;
        min-height: 80px; /* Altura mínima maior no mobile */
    }
    
    .header-content h1 {
        font-size: 1.1rem;
        margin-bottom: 0.1rem;
    }
    
    .header-content .subtitle {
        font-size: 0.7rem;
    }
    
    .container {
        padding: 0.5rem 0.75rem 1rem 0.75rem;
        margin-top: 20px; /* Espaço reduzido para melhor preenchimento */
    }
    
    .system-btn, .market-btn, .timeframe-btn {
        padding: 1rem;
        font-size: 1rem;
    }
    
    .system-icon {
        font-size: 1.5rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    .result-title {
        font-size: 1.1rem;
    }
    
    .result-info {
        font-size: 0.9rem;
    }
    
    .result-entry-time {
        font-size: 1.1rem;
    }
    
    .analysis-container {
        padding: 1.5rem 1rem;
    }
    
    .no-opportunity-container {
        padding: 1.5rem 1rem;
    }
    
    .btn-broker {
        padding: 0.75rem 1.25rem;
        font-size: 0.9rem;
    }
    
    .result-modal-content {
        padding: 1.5rem 1rem;
        max-width: 95%;
    }
    
    .result-modal-emoji {
        font-size: 3rem;
    }
    
    .result-modal-title {
        font-size: 1.5rem;
    }
}

/* ============================================
   MODAL DE RESULTADO
   ============================================ */
.result-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.3s ease-out;
}

.result-modal.show {
    display: flex;
}

.result-modal-content {
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: 2rem 1.5rem;
    max-width: 90%;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.4s ease-out;
    border: 2px solid var(--border-color);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.result-modal-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.result-modal-emoji {
    font-size: 4rem;
    display: block;
    margin-bottom: 0.5rem;
    animation: bounce 0.6s ease-out;
}

@keyframes bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.result-modal-title {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
}

.result-modal-header.win .result-modal-title {
    color: var(--success-color);
}

.result-modal-header.loss .result-modal-title {
    color: var(--danger-color);
}

.result-modal-body {
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1rem;
    line-height: 1.6;
}

.result-modal-body p {
    margin: 0.5rem 0;
}

.result-modal-close {
    width: 100%;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.result-modal-close:hover {
    background: #2563eb;
    transform: translateY(-2px);
}

/* ============================================
   PERFIL
   ============================================ */
.profile-container {
    padding: 1rem;
}

.profile-container h2 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    text-align: center;
}

.profile-section {
    margin-bottom: 2rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
}

.profile-section h3 {
    margin-bottom: 1rem;
    font-size: 1.2rem;
    color: var(--primary-color);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-top: 1rem;
}

.stat-card {
    background: var(--bg-primary);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-primary);
}

.signal-history-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

.signal-history-item {
    background: var(--bg-primary);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.signal-history-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.signal-history-details {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.signal-asset {
    font-weight: bold;
    color: var(--primary-color);
}

.signal-direction {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    background: var(--bg-secondary);
    font-size: 0.875rem;
}

.signal-timeframe {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    background: var(--bg-secondary);
    font-size: 0.875rem;
}

.signal-result {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: bold;
}

.signal-result.win {
    background: var(--success-color);
    color: white;
}

.signal-result.loss {
    background: var(--danger-color);
    color: white;
}

.badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    background: var(--secondary-color);
    color: white;
    font-size: 0.75rem;
}

.asset-stats-list,
.timeframe-stats-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

.asset-stat-item,
.timeframe-stat-item {
    background: var(--bg-primary);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.asset-name,
.timeframe-name {
    font-weight: bold;
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    color: var(--primary-color);
}

.asset-stats-grid,
.timeframe-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.asset-stat,
.timeframe-stat {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.asset-stat-label,
.timeframe-stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.asset-stat-value,
.timeframe-stat-value {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--text-primary);
}

.btn-back {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    display: inline-block;
}

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

/* Desktop: apenas quando necessário */
@media (min-width: 769px) {
    .container {
        max-width: 500px;
        padding: 2rem 1rem;
    }
    
    .result-modal-content {
        max-width: 450px;
    }
}

/* Responsive para perfil */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .asset-stats-grid,
    .timeframe-stats-grid {
        grid-template-columns: 1fr;
    }
    
    .profile-section {
        padding: 1rem;
    }
}
