:root {
    --bg-deep: #090b11;
    --bg-card: rgba(17, 22, 39, 0.7);
    --bg-sidebar: rgba(13, 17, 28, 0.9);
    --accent-primary: #6366f1;
    --accent-primary-glow: rgba(99, 102, 241, 0.35);
    --accent-secondary: #10b981;
    --accent-secondary-glow: rgba(16, 185, 129, 0.25);
    --accent-danger: #f43f5e;
    --accent-warning: #f59e0b;
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(99, 102, 241, 0.4);
    --font-sans: 'Outfit', sans-serif;
    --glow: 0 0 25px var(--accent-primary-glow);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

/* Custom Scrollbar for Chrome/Safari */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

body {
    background-color: var(--bg-deep);
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.12) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(16, 185, 129, 0.08) 0%, transparent 40%);
    color: var(--text-main);
    font-family: var(--font-sans);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

/* App Container Layout */
.app-layout {
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* History Sidebar (Left) */
.history-sidebar {
    width: 320px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-title {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-main);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.history-empty {
    color: var(--text-dim);
    text-align: center;
    padding: 40px 20px;
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.history-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    overflow: hidden;
}

.history-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background: var(--accent-primary);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(99, 102, 241, 0.3);
    transform: translateY(-1px);
}

.history-item:hover::before {
    opacity: 1;
}

.history-item.active {
    background: rgba(99, 102, 241, 0.08);
    border-color: var(--accent-primary);
}

.history-item.active::before {
    opacity: 1;
}

.history-thumb {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background-size: cover;
    background-position: center;
    border: 1px solid var(--border-glass);
}

.history-info {
    flex: 1;
    min-width: 0;
}

.history-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.history-pair {
    font-weight: 600;
    font-size: 0.9rem;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-direction {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
}

.history-direction.buy {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-secondary);
}

.history-direction.sell {
    background: rgba(244, 63, 94, 0.15);
    color: var(--accent-danger);
}

.history-time {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.history-pattern {
    font-size: 0.8rem;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Main Workspace */
.main-workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background: transparent;
}

/* Top App Bar */
.top-bar {
    height: 70px;
    border-bottom: 1px solid var(--border-glass);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    backdrop-filter: blur(8px);
    background: rgba(9, 11, 17, 0.5);
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 1.5rem;
}

.logo-title {
    font-weight: 700;
    font-size: 1.3rem;
    background: linear-gradient(135deg, #fff 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 1.5rem;
    cursor: pointer;
}

/* Workspace Panels */
.panels-container {
    flex: 1;
    display: flex;
    overflow: hidden;
    padding: 24px;
    gap: 24px;
}

.left-panel {
    width: 420px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    padding-right: 4px;
}

.right-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* Glassmorphism Card Style */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.4);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

/* Multi-step progress bar */
.wizard-progress {
    display: flex;
    justify-content: space-between;
    position: relative;
    margin-bottom: 24px;
    padding: 0 10px;
}

.wizard-progress::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 10px;
    right: 10px;
    height: 2px;
    background: var(--border-glass);
    transform: translateY(-50%);
    z-index: 1;
}

.wizard-progress-bar {
    position: absolute;
    top: 50%;
    left: 10px;
    height: 2px;
    background: var(--accent-primary);
    transform: translateY(-50%);
    z-index: 2;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-node {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-deep);
    border: 2px solid var(--border-glass);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-dim);
    position: relative;
    z-index: 3;
    transition: all 0.3s ease;
}

.progress-node.active {
    border-color: var(--accent-primary);
    color: #fff;
    box-shadow: 0 0 10px var(--accent-primary-glow);
}

.progress-node.completed {
    border-color: var(--accent-secondary);
    background: var(--accent-secondary);
    color: #fff;
}

/* Form Wizard Styling */
.form-step {
    display: none;
    opacity: 0;
    transform: translateX(15px);
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-step.active {
    display: block;
    opacity: 1;
    transform: translateX(0);
}

.step-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: #fff;
}

.step-desc {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 20px;
}

/* Bubble buttons */
.bubble-group {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 10px;
}

.bubble-option {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    padding: 16px;
    border-radius: 14px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-dim);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
}

.bubble-option:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.2);
    color: #fff;
    transform: translateY(-2px);
}

.bubble-option.selected {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
    box-shadow: var(--glow);
}

.bubble-option-desc {
    font-size: 0.75rem;
    font-weight: 400;
    opacity: 0.8;
}

/* Custom Pair Input */
.custom-input-container {
    margin-top: 12px;
}

input[type="text"] {
    width: 100%;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-glass);
    padding: 14px 16px;
    border-radius: 12px;
    color: #fff;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.3s;
}

input[type="text"]:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.2);
}

/* Upload zone */
.upload-dropzone {
    border: 2px dashed var(--border-glass);
    border-radius: 16px;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.01);
}

.upload-dropzone:hover, .upload-dropzone.drag-over {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.03);
}

.upload-icon {
    font-size: 2.2rem;
    color: var(--accent-primary);
    transition: transform 0.3s ease;
}

.upload-dropzone:hover .upload-icon {
    transform: translateY(-4px);
}

.upload-text {
    font-size: 0.95rem;
    font-weight: 600;
}

.upload-subtext {
    font-size: 0.75rem;
    color: var(--text-dim);
}

/* Preview Image */
.preview-container {
    position: relative;
    width: 100%;
    height: 180px;
    margin-top: 20px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-glass);
    display: none;
}

.preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

.preview-remove-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(244, 63, 94, 0.85);
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.preview-remove-btn:hover {
    background: var(--accent-danger);
    transform: scale(1.1);
}

/* Buttons */
.wizard-nav-btns {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border-glass);
    color: var(--text-main);
    padding: 14px 20px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--text-dim);
}

.btn-primary {
    flex: 1;
    background: linear-gradient(135deg, var(--accent-primary), #4f46e5);
    color: white;
    border: none;
    padding: 14px 20px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.2);
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-success {
    background: linear-gradient(135deg, var(--accent-secondary), #059669);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.25);
}

.btn-success:hover {
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

/* Disclaimer Box */
.info-box {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.18);
    padding: 14px 18px;
    border-radius: 12px;
    font-size: 0.8rem;
    color: #fbbf24;
    line-height: 1.5;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.info-box-icon {
    font-size: 1.1rem;
    margin-top: 1px;
}

/* Loader Workspace */
.loader-panel {
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 20px;
    min-height: 300px;
}

.loader-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(99, 102, 241, 0.1);
    border-top: 4px solid var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s cubic-bezier(0.55, 0.15, 0.45, 0.85) infinite;
}

.loader-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.5px;
}

.loader-sub {
    font-size: 0.85rem;
    color: var(--text-dim);
}

/* Results / Trading Terminal Workspace */
.results-panel {
    display: none;
    flex-direction: column;
    gap: 24px;
    animation: fadeIn 0.6s ease-out;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-glass);
    padding-bottom: 16px;
}

.results-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
}

/* Dynamic Direction Badge */
.direction-badge {
    padding: 6px 16px;
    border-radius: 30px;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.direction-badge.buy {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid var(--accent-secondary);
    color: var(--accent-secondary);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.15);
}

.direction-badge.sell {
    background: rgba(244, 63, 94, 0.15);
    border: 1px solid var(--accent-danger);
    color: var(--accent-danger);
    box-shadow: 0 0 15px rgba(244, 63, 94, 0.15);
}

/* Grid of Statistics */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 16px;
}

.stats-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-glass);
    padding: 16px;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.confidence-card {
    grid-column: 1 / -1;
}

@media (max-width: 576px) {
    .confidence-card .confidence-flex {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 12px !important;
    }
    .confidence-card #confidenceReasons {
        border-left: none !important;
        padding-left: 0 !important;
        border-top: 1px solid var(--border-glass);
        padding-top: 12px;
        width: 100%;
    }
}

.stats-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    color: var(--text-dim);
    letter-spacing: 1px;
    font-weight: 600;
}

.stats-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
}

.stats-value.highlight-buy {
    color: var(--accent-secondary);
}

.stats-value.highlight-sell {
    color: var(--accent-danger);
}

/* Risk-to-Reward Ratio bar or info */
.rr-container {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-glass);
    padding: 20px;
    border-radius: 16px;
}

.rr-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 0.9rem;
}

.rr-label {
    font-weight: 600;
    color: var(--text-dim);
}

.rr-value {
    font-weight: 700;
    color: #fff;
}

.rr-bar-bg {
    height: 8px;
    background: rgba(244, 63, 94, 0.3); /* stop loss end */
    border-radius: 4px;
    position: relative;
    overflow: hidden;
    display: flex;
}

.rr-bar-fill {
    height: 100%;
    background: var(--accent-secondary); /* target end */
    transition: width 0.4s ease;
}

/* Summary Panel */
.summary-panel {
    background: rgba(99, 102, 241, 0.06);
    border-left: 4px solid var(--accent-primary);
    padding: 20px;
    border-radius: 0 12px 12px 0;
}

.summary-heading {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 6px;
    color: #fff;
}

.summary-text {
    font-size: 0.92rem;
    line-height: 1.6;
    color: var(--text-main);
}

/* Before / After Slider Component */
.slider-container {
    position: relative;
    width: 100%;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border-glass);
    aspect-ratio: 16 / 9;
}

.slider-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #0f1219;
}

.slider-img.img-before {
    z-index: 10;
}

.slider-img.img-after {
    z-index: 20;
    clip-path: polygon(0 0, 50% 0, 50% 100%, 0 100%);
}

.slider-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 4px;
    background: var(--text-main);
    z-index: 30;
    transform: translateX(-50%);
    cursor: ew-resize;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.slider-handle::after {
    content: '↔';
    position: absolute;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--text-main);
    color: var(--bg-deep);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    font-size: 0.9rem;
}

.slider-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    z-index: 40;
    cursor: ew-resize;
}

.slider-labels {
    position: absolute;
    bottom: 12px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 25;
    pointer-events: none;
}

.slider-label-badge {
    background: rgba(9, 11, 17, 0.75);
    border: 1px solid var(--border-glass);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: #fff;
    text-transform: uppercase;
}

/* Warnings and fallbacks */
.warning-box {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: 8px;
    padding: 12px;
    font-size: 0.8rem;
    color: var(--accent-warning);
    margin-top: 12px;
}

/* Educational patterns detail card */
.pattern-education {
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid var(--border-glass);
    padding: 20px;
    border-radius: 16px;
    margin-top: 12px;
}

.pattern-edu-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: #fff;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pattern-edu-desc {
    font-size: 0.88rem;
    line-height: 1.5;
    color: var(--text-dim);
}

/* Utility Animations */
@keyframes spin {
    to { transform: rotate(360deg); }
}

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

/* Responsive Rules */
@media (max-width: 1024px) {
    .panels-container {
        flex-direction: column;
        overflow-y: auto;
        padding: 16px;
    }
    .left-panel {
        width: 100%;
        overflow-y: visible;
        padding-right: 0;
    }
    .right-panel {
        overflow-y: visible;
    }
    .app-layout {
        overflow-y: auto;
        height: auto;
    }
    .main-workspace {
        height: auto;
        overflow: visible;
    }
}

@media (max-width: 768px) {
    .history-sidebar {
        position: fixed;
        left: 0;
        top: 70px;
        bottom: 0;
        transform: translateX(-100%);
        box-shadow: 10px 0 30px rgba(0,0,0,0.5);
    }
    .history-sidebar.open {
        transform: translateX(0);
    }
    .mobile-menu-btn {
        display: block;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
