@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Outfit:wght@400;500;600;700&display=swap');

:root {
    --bg-dark: #070a12;
    --card-bg: rgba(17, 24, 39, 0.75);
    --card-border: rgba(255, 255, 255, 0.08);
    --primary: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.35);
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.3);
    --warning: #f59e0b;
    --danger: #ef4444;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent-purple: #8b5cf6;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.12) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(139, 92, 246, 0.12) 0px, transparent 50%),
        radial-gradient(at 50% 100%, rgba(16, 185, 129, 0.08) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    padding-bottom: 60px;
}

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

/* Glassmorphism Header */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(11, 15, 25, 0.85);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--card-border);
    padding: 18px 0;
    margin-bottom: 30px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--accent-purple));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 0 20px var(--primary-glow);
}

.brand-text h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #ffffff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-text p {
    font-size: 12px;
    color: var(--text-muted);
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 6px 14px;
    border-radius: 30px;
    font-size: 12px;
    font-weight: 600;
    color: var(--success);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--success);
    box-shadow: 0 0 10px var(--success);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Control Panel */
.control-panel {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.panel-title {
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) auto;
    gap: 18px;
    align-items: end;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group select, .form-group input {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 12px 14px;
    color: var(--text-main);
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
}

.form-group select:focus, .form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 12px var(--primary-glow);
}

/* Toggle Switch Styling */
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}
.switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #334155;
    transition: .3s;
    border-radius: 24px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}
input:checked + .slider {
    background-color: #10b981;
}
input:checked + .slider:before {
    transform: translateX(24px);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #2563eb);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 12px 24px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px var(--primary-glow);
    height: 45px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--primary-glow);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.metric-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 20px;
    backdrop-filter: blur(12px);
    transition: all 0.2s ease;
}

.metric-card:hover {
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.metric-card.success { border-left: 4px solid var(--success); }
.metric-card.warning { border-left: 4px solid var(--warning); }
.metric-card.purple { border-left: 4px solid var(--accent-purple); }

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

.metric-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.metric-icon {
    font-size: 18px;
}

.metric-value {
    font-family: 'Outfit', sans-serif;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}

.metric-sub {
    font-size: 12px;
    color: var(--text-muted);
}

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

/* Comparison Table */
.comparison-section {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 30px;
}

.comp-table-container {
    overflow-x: auto;
    margin-top: 15px;
}

.comp-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 14px;
}

.comp-table th, .comp-table td {
    padding: 14px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.comp-table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
}

/* Detailed Trades Table */
.trades-section {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 24px;
}

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

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

.trades-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.trades-table th {
    background: rgba(15, 23, 42, 0.6);
    color: var(--text-muted);
    font-weight: 600;
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--card-border);
}

.trades-table td {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.trades-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* Badges */
.badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    display: inline-block;
}

.badge-strategy {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 3px 9px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    line-height: 1.4;
    vertical-align: middle;
}

.badge-wolfe-wave {
    background: rgba(14, 165, 233, 0.12);
    border: 1px solid rgba(14, 165, 233, 0.35);
    color: #38bdf8;
}

.badge-tony-swing {
    background: rgba(139, 92, 246, 0.12);
    border: 1px solid rgba(139, 92, 246, 0.35);
    color: #c4b5fd;
}

.badge-buy { background: rgba(16, 185, 129, 0.2); color: var(--success); border: 1px solid var(--success); }
.badge-sell { background: rgba(239, 68, 68, 0.2); color: var(--danger); border: 1px solid var(--danger); }
.badge-full { background: rgba(59, 130, 246, 0.2); color: var(--primary); border: 1px solid var(--primary); }
.badge-reduced { background: rgba(245, 158, 11, 0.2); color: var(--warning); border: 1px solid var(--warning); }
.badge-pass { background: rgba(148, 163, 184, 0.2); color: var(--text-muted); border: 1px solid var(--text-muted); }
.badge-tf { background: rgba(139, 92, 246, 0.2); color: var(--accent-purple); border: 1px solid var(--accent-purple); }

/* K.O. Micro-Chips */
.ko-micro-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-width: 280px;
}

.ko-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10.5px;
    font-weight: 600;
    white-space: nowrap;
}

.ko-chip-strike {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #f87171;
}

.ko-chip-lev {
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.35);
    color: #34d399;
}

.ko-chip-qty {
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.35);
    color: #60a5fa;
}

.ko-chip-pnl {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.35);
    color: #fbbf24;
}

/* Trigger Distance Gauge */
.trigger-gauge-container {
    display: flex;
    flex-direction: column;
    min-width: 145px;
    gap: 4px;
}

.distance-progress-bar {
    width: 100%;
    height: 5px;
    background: #1e293b;
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid #334155;
}

.distance-progress-fill {
    height: 100%;
    transition: width 0.3s ease;
}

.fill-hot {
    background: linear-gradient(90deg, #f59e0b, #ef4444);
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.6);
}

.fill-normal {
    background: linear-gradient(90deg, #38bdf8, #818cf8);
}

.dist-badge {
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 3px;
    font-weight: 700;
}

.dist-hot {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.5);
    animation: pulse 1.5s infinite;
}

.dist-normal {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.btn-chart {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid var(--primary);
    color: var(--text-main);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-chart:hover {
    background: var(--primary);
    color: white;
}

/* Modal Window */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background-color: rgba(7, 10, 18, 0.85);
    backdrop-filter: blur(10px);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: #0f172a;
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 24px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

.modal-close {
    position: absolute;
    right: 20px; top: 20px;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close:hover { color: var(--text-main); }

/* Inline Chart Zoom Styling */
.chart-zoomed {
    position: fixed !important;
    top: 5% !important;
    left: 5% !important;
    width: 90vw !important;
    max-width: 90vw !important;
    height: 85vh !important;
    object-fit: contain !important;
    z-index: 10000 !important;
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.95) !important;
    border: 2px solid #38bdf8 !important;
    border-radius: 12px !important;
    background: #0f172a !important;
    cursor: zoom-out !important;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   MOBILE-FIRST RESPONSIVE OPTIMIZATIONS (TABLETS & SMARTPHONES)
   ========================================================================== */

/* Universal Scroll & Table Wrapper Protection */
html, body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

.table-container, .table-wrapper, .radar-table-container, .card-body, .journal-container {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    display: block;
    margin-bottom: 12px;
}

table {
    border-collapse: separate;
    border-spacing: 0;
    min-width: 720px;
    width: 100%;
}

/* Smooth Touch-Scrollbar for Mobile */
.table-container::-webkit-scrollbar,
.table-wrapper::-webkit-scrollbar,
.radar-table-container::-webkit-scrollbar {
    height: 6px;
}
.table-container::-webkit-scrollbar-thumb,
.table-wrapper::-webkit-scrollbar-thumb,
.radar-table-container::-webkit-scrollbar-thumb {
    background: rgba(59, 130, 246, 0.4);
    border-radius: 4px;
}

/* 1. TABLET BREAKPOINT (max-width: 1024px) */
@media (max-width: 1024px) {
    .container {
        padding: 0 16px;
    }
    .header-content {
        flex-wrap: wrap;
        gap: 14px;
    }
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    .form-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* 2. SMARTPHONE BREAKPOINT (max-width: 768px) */
@media (max-width: 768px) {
    body {
        padding-bottom: 40px;
    }
    
    .container {
        padding: 0 10px;
    }

    header {
        padding: 12px 0;
        margin-bottom: 16px;
    }

    .header-content {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .brand {
        justify-content: flex-start;
        width: 100%;
    }

    .brand-icon {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }

    .brand-text h1 {
        font-size: 17px;
        line-height: 1.2;
    }

    .brand-text p {
        font-size: 10.5px;
    }

    /* Mobile Header Action Row */
    .header-actions-mobile {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
        width: 100%;
        justify-content: space-between;
    }

    .ab-toggle-wrapper {
        width: 100%;
        justify-content: space-between;
    }

    .status-badge {
        font-size: 11px;
        padding: 4px 10px;
    }

    /* Control Panel & Form */
    .control-panel {
        padding: 16px;
        margin-bottom: 18px;
        border-radius: 12px;
    }

    .form-grid {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }

    .btn-primary, .btn {
        width: 100%;
        min-height: 42px;
        justify-content: center;
        font-size: 13px !important;
    }

    /* Metric & Stat Cards */
    .metrics-grid, .summary-cards {
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
    }

    .metric-card, .stat-card {
        padding: 12px !important;
    }

    .metric-value {
        font-size: 18px !important;
    }

    .metric-label {
        font-size: 10px !important;
    }

    /* Table Adjustments */
    th, td {
        padding: 8px 10px !important;
        font-size: 11px !important;
    }

    .ko-micro-chips {
        max-width: 200px;
    }

    .ko-chip {
        font-size: 9.5px;
        padding: 1px 4px;
    }

    .badge-strategy {
        font-size: 9.5px;
        padding: 2px 6px;
    }

    /* Modal on Mobile */
    .modal-content {
        width: 95vw !important;
        max-width: 95vw !important;
        padding: 16px !important;
        border-radius: 14px;
        margin: 10px auto;
    }

    .chart-zoomed {
        top: 2% !important;
        left: 2% !important;
        width: 96vw !important;
        max-width: 96vw !important;
        height: 80vh !important;
    }
}

/* 3. SMALL MOBILE SCREEN (max-width: 480px) */
@media (max-width: 480px) {
    .metrics-grid, .summary-cards {
        grid-template-columns: 1fr !important;
    }

    .brand-text h1 {
        font-size: 15px;
    }

    .panel-title {
        font-size: 14px;
    }
}
