/**
 * MTF Trading Bot - Web Dashboard Styles
 * Modern, responsive design with dark/light theme support
 * Enhanced for v3.1
 */

/* ============================================================================
   CSS VARIABLES (Theme Colors)
   ============================================================================ */

:root {
    /* Primary Colors */
    --primary-color: #667eea;
    --primary-dark: #5568d3;
    --secondary-color: #764ba2;
    
    /* Background Colors */
    --bg-color: #0f172a;
    --panel-bg: #1e293b;
    --border-color: #334155;
    
    /* Text Colors */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    /* Status Colors */
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.2);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.3);
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* Light Theme (Optional) */
@media (prefers-color-scheme: light) {
    :root {
        --bg-color: #f8fafc;
        --panel-bg: #ffffff;
        --border-color: #e2e8f0;
        --text-primary: #1e293b;
        --text-secondary: #475569;
        --text-muted: #94a3b8;
    }
}

/* ============================================================================
   GLOBAL RESET & BASE STYLES
   ============================================================================ */

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

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

/* ============================================================================
   CONTAINER & LAYOUT
   ============================================================================ */

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* ============================================================================
   HEADER
   ============================================================================ */

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-xl);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.logo h1 {
    font-size: 2em;
    font-weight: 700;
    color: white;
    margin-bottom: 5px;
}

.subtitle {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1em;
    font-weight: 400;
}

.header-actions {
    display: flex;
    gap: 15px;
    align-items: center;
}

/* Status Badge */
.status-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    padding: 10px 20px;
    border-radius: 25px;
    color: white;
    font-weight: 500;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #10b981;
    animation: pulse 2s ease-in-out infinite;
}

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

/* ============================================================================
   STATS GRID (Top 4 Cards)
   ============================================================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--panel-bg);
    padding: 25px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: all var(--transition-normal);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.stat-icon {
    font-size: 2.5em;
    opacity: 0.8;
}

.stat-content h3 {
    font-size: 1.8em;
    font-weight: 700;
    margin-bottom: 5px;
    color: var(--primary-color);
}

.stat-content p {
    color: var(--text-secondary);
    font-size: 0.9em;
}

/* ============================================================================
   CONTENT GRID
   ============================================================================ */

.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 25px;
}

/* ============================================================================
   PANELS
   ============================================================================ */

.panel {
    background: var(--panel-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: all var(--transition-normal);
}

.panel:hover {
    box-shadow: var(--shadow-lg);
}

.panel-header {
    padding: 20px;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(to right, rgba(102, 126, 234, 0.1), transparent);
}

.panel-header h2 {
    font-size: 1.3em;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-body {
    padding: 20px;
}

/* ============================================================================
   BUTTONS
   ============================================================================ */

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95em;
    transition: all var(--transition-normal);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.85em;
}

/* ============================================================================
   TABLE
   ============================================================================ */

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

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

thead {
    background: linear-gradient(to right, rgba(102, 126, 234, 0.1), transparent);
}

th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
}

td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
}

tbody tr {
    transition: all var(--transition-fast);
}

tbody tr:hover {
    background: rgba(102, 126, 234, 0.05);
}

/* ============================================================================
   BADGES
   ============================================================================ */

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
    text-transform: uppercase;
}

.badge.long {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success-color);
}

.badge.short {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger-color);
}

.badge.active {
    background: rgba(59, 130, 246, 0.2);
    color: var(--info-color);
}

.badge.closed {
    background: rgba(100, 116, 139, 0.2);
    color: var(--text-muted);
}

/* ============================================================================
   TEXT COLORS
   ============================================================================ */

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

.text-success {
    color: var(--success-color);
}

.text-danger {
    color: var(--danger-color);
}

.text-warning {
    color: var(--warning-color);
}

.text-info {
    color: var(--info-color);
}

.text-muted {
    color: var(--text-muted);
}

/* ============================================================================
   SIGNAL LIST
   ============================================================================ */

.signal-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.signal-item {
    background: var(--bg-color);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: all var(--transition-fast);
}

.signal-item:hover {
    border-color: var(--primary-color);
    transform: translateX(5px);
}

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

.signal-symbol {
    font-weight: 700;
    font-size: 1.1em;
}

.signal-details {
    display: flex;
    gap: 15px;
    font-size: 0.85em;
    color: var(--text-secondary);
}

.signal-status {
    display: flex;
    align-items: center;
    gap: 5px;
}

.signal-status.status-active {
    color: var(--info-color);
}

.signal-status.status-tp {
    color: var(--success-color);
}

.signal-status.status-sl {
    color: var(--danger-color);
}

.signal-status.status-expired {
    color: var(--text-muted);
}

/* ============================================================================
   STATS LIST
   ============================================================================ */

.stats-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

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

.stat-row.highlight {
    background: linear-gradient(to right, rgba(102, 126, 234, 0.1), transparent);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--primary-color);
}

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

.stat-value {
    font-weight: 600;
    font-size: 1em;
    color: var(--text-primary);
}

/* ============================================================================
   CHART CONTAINER
   ============================================================================ */

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* ============================================================================
   LOADING & ERROR STATES
   ============================================================================ */

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    font-size: 1.1em;
}

.loading::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

.no-data {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 1em;
}

.error {
    text-align: center;
    padding: 40px;
    color: var(--danger-color);
    font-size: 1em;
}

/* ============================================================================
   FOOTER
   ============================================================================ */

.footer {
    margin-top: 50px;
    padding: 30px;
    text-align: center;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
}

.footer p {
    margin-bottom: 10px;
    font-size: 0.9em;
}

.footer strong {
    color: var(--primary-color);
}

.divider {
    margin: 0 15px;
    color: var(--border-color);
}

.footer-update {
    color: var(--text-muted);
    font-size: 0.85em;
}

.footer-disclaimer {
    margin-top: 20px;
    padding: 15px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.85em;
    line-height: 1.6;
}

/* ============================================================================
   SCROLLBAR STYLING
   ============================================================================ */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

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

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

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

/* Tablet */
@media (max-width: 1024px) {
    .container {
        padding: 15px;
    }
    
    .header {
        padding: 20px;
    }
    
    .logo h1 {
        font-size: 1.5em;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
    
    .content-grid {
        grid-template-columns: 1fr;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .header {
        flex-direction: column;
        text-align: center;
        padding: 20px;
    }
    
    .logo h1 {
        font-size: 1.3em;
    }
    
    .subtitle {
        font-size: 0.9em;
    }
    
    .header-actions {
        width: 100%;
        justify-content: center;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-card {
        padding: 20px;
    }
    
    .stat-icon {
        font-size: 2em;
    }
    
    .stat-content h3 {
        font-size: 1.5em;
    }
    
    .panel-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .panel-header h2 {
        font-size: 1.1em;
    }
    
    .table-container {
        font-size: 0.85em;
    }
    
    th, td {
        padding: 8px;
    }
    
    .footer {
        padding: 20px 10px;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    html {
        font-size: 14px;
    }
    
    .logo h1 {
        font-size: 1.2em;
    }
    
    .stat-content h3 {
        font-size: 1.3em;
    }
    
    .btn {
        padding: 8px 16px;
        font-size: 0.9em;
    }
    
    .signal-details {
        flex-direction: column;
        gap: 5px;
    }
}

/* ============================================================================
   ANIMATIONS
   ============================================================================ */

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

.fade-in {
    animation: fadeIn 0.5s ease;
}

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

.slide-in {
    animation: slideIn 0.5s ease;
}

/* ============================================================================
   UTILITY CLASSES
   ============================================================================ */

.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.d-flex {
    display: flex;
}

.align-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-10 {
    gap: 10px;
}

.gap-20 {
    gap: 20px;
}

.mt-10 {
    margin-top: 10px;
}

.mt-20 {
    margin-top: 20px;
}

.mb-10 {
    margin-bottom: 10px;
}

.mb-20 {
    margin-bottom: 20px;
}

.p-10 {
    padding: 10px;
}

.p-20 {
    padding: 20px;
}

/* ============================================================================
   PRINT STYLES
   ============================================================================ */

@media print {
    .header-actions,
    .footer-disclaimer,
    .btn {
        display: none;
    }
    
    body {
        background: white;
        color: black;
    }
    
    .panel {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* ============================================================================
   END OF STYLES
   ============================================================================ */
