/* Базовые стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    color: #e0e0e0;
    min-height: 100vh;
}

/* Контейнер */
.dashboard-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Заголовок */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    margin-bottom: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

header h1 {
    font-size: 1.8rem;
    background: linear-gradient(90deg, #00d4ff, #7b2ff7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Кнопка выхода */
#logoutBtn {
    padding: 10px 20px;
    background: rgba(255, 100, 100, 0.2);
    border: 1px solid rgba(255, 100, 100, 0.3);
    color: #ff6b6b;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#logoutBtn:hover {
    background: rgba(255, 100, 100, 0.3);
    transform: translateY(-2px);
}

/* Вкладки */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 15px 25px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #aaa;
    border-radius: 12px 12px 0 0;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.tab-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    transition: left 0.5s ease;
}

.tab-btn:hover::before {
    left: 100%;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.tab-btn.active {
    background: linear-gradient(135deg, #00d4ff 0%, #7b2ff7 100%);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(0, 212, 255, 0.3);
}

/* Контент вкладок */
.tab-content {
    display: none;
    animation: fadeIn 0.4s ease;
}

.tab-content.active {
    display: block;
}

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

/* Основной контент */
.main-content {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 0 15px 15px 15px;
    padding: 30px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

/* Карточки */
.status-panel, .positions-panel, .logs-panel, .settings-panel, .stats-panel {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

h2 {
    margin-bottom: 20px;
    color: #00d4ff;
    font-size: 1.4rem;
    border-bottom: 2px solid rgba(0, 212, 255, 0.3);
    padding-bottom: 10px;
}

/* Статус карточка */
.status-card {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.1), rgba(123, 47, 247, 0.1));
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.status-item {
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.status-item .label {
    color: #888;
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.status-item .value {
    font-size: 1.5rem;
    font-weight: bold;
}

.status-item .value.running {
    color: #00ff88;
}

.status-item .value.stopped {
    color: #ff6b6b;
}

/* Кнопки управления */
.control-buttons {
    display: flex;
    gap: 15px;
    margin: 20px 0;
}

.btn-start, .btn-stop {
    padding: 15px 30px;
    font-size: 1.1rem;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
}

.btn-start {
    background: linear-gradient(135deg, #00ff88, #00cc6a);
    color: #000;
}

.btn-start:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 255, 136, 0.4);
}

.btn-start:disabled {
    background: #333;
    color: #666;
    cursor: not-allowed;
}

.btn-stop {
    background: linear-gradient(135deg, #ff6b6b, #ee5a5a);
    color: #fff;
}

.btn-stop:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(255, 107, 107, 0.4);
}

.btn-stop:disabled {
    background: #333;
    color: #666;
    cursor: not-allowed;
}

.control-hint {
    color: #666;
    font-size: 0.9rem;
    margin-top: 15px;
}

/* Логи */
.logs-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.btn-small {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #aaa;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-small:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

#logsContainer {
    background: #0a0a0a;
    border-radius: 10px;
    padding: 20px;
    max-height: 500px;
    overflow-y: auto;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#logsContainer::-webkit-scrollbar {
    width: 10px;
}

#logsContainer::-webkit-scrollbar-track {
    background: #1a1a1a;
}

#logsContainer::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 5px;
}

#logsContainer::-webkit-scrollbar-thumb:hover {
    background: #444;
}

/* Таблица позиций */
#positionsTable {
    overflow-x: auto;
}

#positionsTable table {
    width: 100%;
    border-collapse: collapse;
}

#positionsTable th, #positionsTable td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#positionsTable th {
    background: rgba(0, 212, 255, 0.1);
    color: #00d4ff;
    font-weight: 600;
}

#positionsTable tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Настройки */
#settingsForm {
    display: grid;
    gap: 15px;
}

#settingsForm label {
    display: block;
    margin-bottom: 5px;
    color: #aaa;
}

#settingsForm input, #settingsForm select {
    width: 100%;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: #fff;
}

#saveSettingsBtn {
    margin-top: 20px;
    padding: 12px 25px;
    background: linear-gradient(135deg, #00d4ff, #7b2ff7);
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
}

#saveSettingsBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0, 212, 255, 0.4);
}

/* Статистика */
.stats-panel .loading {
    color: #666;
    text-align: center;
    padding: 40px;
}

/* Адаптивность */
@media (max-width: 768px) {
    .tabs {
        flex-direction: column;
    }
    
    .tab-btn {
        border-radius: 8px;
    }
    
    .control-buttons {
        flex-direction: column;
    }
    
    .status-card {
        grid-template-columns: 1fr;
    }
    
    header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
}

/* Скроллбары */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #1a1a2e;
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #444;
}

/* Настройки */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.settings-section {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.settings-section h3 {
    color: #00d4ff;
    font-size: 1rem;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(0, 212, 255, 0.2);
}

.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    color: #888;
    font-size: 0.85rem;
    margin-bottom: 5px;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select {
    width: 100%;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: #fff;
    font-size: 0.9rem;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #00d4ff;
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.2);
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: #aaa;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #00d4ff;
}

#settingsForm button[type="submit"] {
    width: 100%;
    padding: 15px;
    font-size: 1.1rem;
}

/* Модальные окна - тёмный текст на светлом фоне */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    margin: 5% auto;
    padding: 25px;
    border: 1px solid #00d4ff;
    border-radius: 15px;
    width: 80%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.3);
}

.modal-content h2 {
    color: #00d4ff;
    margin-top: 0;
    border-bottom: 1px solid #333;
    padding-bottom: 10px;
}

.modal-content h3 {
    color: #00ff88;
    margin: 15px 0 10px;
}

.modal-content p,
.modal-content li,
.modal-content td,
.modal-content th,
.modal-content span,
.modal-content div {
    color: #e0e0e0 !important;
}

.modal-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
}

.modal-content th {
    background: rgba(0, 212, 255, 0.1);
    color: #00d4ff !important;
    padding: 10px;
    text-align: left;
}

.modal-content td {
    padding: 8px 10px;
    border-bottom: 1px solid #333;
}

.modal-close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.modal-close:hover {
    color: #fff;
}

/* TradingView виджеты - тёмная тема */
.tradingview-widget-container,
.tv-lightweight-charts-wrapper,
iframe[src*='tradingview'] {
    background: #0d1117 !important;
    border-radius: 12px !important;
    overflow: hidden;
}

/* Переопределение стилей внутри iframe TradingView через parent */
.tv-widget .header,
.tv-widget .title,
.tv-container .wrapper,
.tv-chart-container {
    background: #0d1117 !important;
}

/* Все элементы внутри виджета */
div[class*='tv-'],
div[id*='tradingview'],
span[class*='tv-'] {
    background-color: transparent !important;
    color: #e0e0e0 !important;
}

/* Формы и кнопки в виджетах */
input, select, button {
    background: #1a1a2e !important;
    color: #e0e0e0 !important;
    border: 1px solid #333 !important;
}

/* Скроллбары */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #1a1a2e;
}

::-webkit-scrollbar-thumb {
    background: #00d4ff;
    border-radius: 4px;
}

/* Login styles */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

.login-box {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-box h1 {
    color: #00d9ff;
    margin-bottom: 30px;
    font-size: 28px;
}

.login-box .form-group {
    margin-bottom: 20px;
    text-align: left;
}

.login-box label {
    display: block;
    color: #a0a0a0;
    margin-bottom: 8px;
    font-size: 14px;
}

.login-box input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid rgba(0, 217, 255, 0.3);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.3);
    color: #ffffff;
    font-size: 16px;
    box-sizing: border-box;
}

.login-box input:focus {
    outline: none;
    border-color: #00d9ff;
    box-shadow: 0 0 10px rgba(0, 217, 255, 0.3);
}

.login-box button {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #00d9ff 0%, #0099cc 100%);
    border: none;
    border-radius: 8px;
    color: #000;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 10px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.login-box button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0, 217, 255, 0.4);
}

.login-box .error-message {
    color: #ff4444;
    margin-top: 15px;
    font-size: 14px;
}

/* Таблица сделок в статистике */
.trades-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    font-size: 13px;
}
.trades-table th, .trades-table td {
    padding: 8px;
    text-align: left;
    border-bottom: 1px solid #333;
}
.trades-table th {
    background: #1a1a2e;
    color: #00d4ff;
}
.trades-table .profit-positive {
    color: #00ff88;
}
.trades-table .profit-negative {
    color: #ff6b6b;
}
