@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --bg-main: #0b0e11;
    --bg-card: #1e2329;
    --bg-input: #2b3139;
    --primary: #fcd535;
    --primary-hover: #e6c229;
    --success: #0ecb81;
    --danger: #f6465d;
    --warning: #f0b90b;
    --text-main: #eaecef;
    --text-muted: #848e9c;
    --border: #353945;
    --radius: 8px;
    --font-sans: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg-main: #f0f2f5;
    --bg-card: #ffffff;
    --bg-input: #f5f5f5;
    --primary: #c99400;
    --text-main: #1e2329;
    --text-muted: #707a8a;
    --border: #e6e8ea;
}

/* Suggestions Dropdown */
.suggestions-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: 5px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 2000;
    display: none;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.suggestion-item {
    padding: 0.8rem 1rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-main);
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
    font-family: var(--font-mono);
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background: var(--bg-input);
    color: var(--primary);
    padding-left: 1rem;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font-sans);
    line-height: 1.5;
    overflow-x: hidden;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
}

.logo span {
    color: var(--primary);
}

/* Main Grid Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: 350px 1fr 300px;
    gap: 1.5rem;
}

@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 900px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#liveMarketPrice {
    font-family: var(--font-mono);
    color: var(--success);
    font-weight: 700;
    font-size: 1.1rem;
}

/* Form Elements */
.input-group {
    margin-bottom: 1rem;
}

.input-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

input,
select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 0.75rem 1rem;
    color: var(--text-main);
    font-size: 1rem;
    transition: var(--transition);
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
}

.input-suffix {
    position: absolute;
    right: 1rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    pointer-events: none;
}

.btn-input-action {
    position: absolute;
    right: 3.8rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--primary);
    padding: 2px 8px;
    font-size: 0.7rem;
    border-radius: 3px;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    z-index: 5;
}

.btn-input-action:hover {
    background: var(--primary);
    color: #000;
}

/* Selectors (Side & Leverage) */
.toggle-group {
    display: flex;
    background: var(--bg-input);
    padding: 4px;
    border-radius: 4px;
    gap: 4px;
    margin-bottom: 1rem;
}

.toggle-btn {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-muted);
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
}

.toggle-btn.active.long {
    background: var(--success);
    color: white;
}

.toggle-btn.active.short {
    background: var(--danger);
    color: white;
}

/* Leverage Slider */
.leverage-container {
    margin-bottom: 1.5rem;
}

.leverage-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary);
    border-radius: 50%;
}

/* Quick Buttons */
.quick-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.4rem;
    font-size: 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Metric Rows */
.metric-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.metric-label {
    color: var(--text-muted);
}

.metric-value {
    font-weight: 500;
}

.pnl-positive {
    color: var(--success);
}

.pnl-negative {
    color: var(--danger);
}

/* Price Scale Visualizer */
.price-scale {
    position: relative;
    height: 100%;
    background: rgba(255, 255, 255, 0.02);
    border-right: 2px solid var(--border);
    margin-right: 3rem;
    padding: 2rem 0;
}

.viz-wrapper {
    height: 500px;
}

.price-mark {
    position: absolute;
    right: -2px;
    width: 12px;
    height: 2px;
    background: var(--border);
}

.price-label {
    position: absolute;
    right: 15px;
    transform: translateY(-50%);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.price-indicator {
    position: absolute;
    left: 100%;
    transform: translateY(-50%);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 10;
    margin-left: 10px;
    font-weight: 600;
}

.indicator-entry {
    background: var(--text-muted);
    color: var(--bg-main);
}

.indicator-liq {
    background: var(--danger);
    color: white;
}

.indicator-target {
    background: var(--success);
    color: white;
}

.price-line {
    position: absolute;
    left: 0;
    right: -20px;
    height: 1px;
    border-top: 1px dashed rgba(255, 255, 255, 0.2);
}

/* Risk Meter */
.risk-meter {
    height: 10px;
    background: var(--bg-input);
    border-radius: 5px;
    overflow: hidden;
    margin: 1rem 0;
}

.risk-fill {
    height: 100%;
    width: 0%;
    transition: width 0.5s ease-out, background-color 0.3s;
}

/* Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    animation: fadeIn 0.4s ease-out backwards;
}

.card:nth-child(2) {
    animation-delay: 0.1s;
}

.card:nth-child(3) {
    animation-delay: 0.2s;
}

/* Chart Header Styles */
.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.chart-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.zoom-controls {
    display: flex;
    gap: 5px;
}

.projections-input-row {
    display: flex;
    gap: 8px;
    margin-bottom: 1rem;
}

/* Mobile Optimizations */
/* Mobile Optimizations */
@media (max-width: 900px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .viz-wrapper {
        height: 400px;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 1rem;
    }

    .dashboard-grid {
        gap: 1rem;
    }

    .quick-grid {
        grid-template-columns: repeat(4, 1fr);
        /* Keep 4 buttons if they fit, or 2 if text is long */
    }

    .viz-wrapper {
        height: 350px;
    }

    .price-scale {
        margin-right: 1.5rem;
    }

    .header-actions {
        display: flex;
        gap: 0.5rem;
    }

    .header-actions button {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
    }

    header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .projections-input-row {
        flex-direction: column;
    }

    .projections-input-row>div {
        width: 100% !important;
        flex: auto !important;
    }

    .chart-header {
        flex-direction: column;
        align-items: stretch;
    }

    .chart-header-left {
        justify-content: space-between;
        width: 100%;
    }

    .zoom-controls {
        justify-content: space-between;
        width: 100%;
        margin-top: 0.5rem;
    }

    .zoom-controls button {
        flex: 1;
        text-align: center;
        padding: 6px;
    }

    #liveMarketPrice {
        font-size: 0.9rem;
    }

    #timeframeSelect {
        padding: 0.2rem 0.4rem;
        font-size: 0.8rem;
    }
}

@media (max-width: 400px) {
    .quick-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .logo {
        font-size: 1.2rem;
    }

    .header-actions button {
        padding: 0.3rem 0.5rem;
        font-size: 0.7rem;
    }
}

/* Screenshot Mode */
body.screenshot-mode header,
body.screenshot-mode .calc-analysis .card:last-child,
body.screenshot-mode #savePresetBtn {
    display: none !important;
}

body.screenshot-mode .container {
    padding: 20px;
    max-width: 1200px;
}

body.screenshot-mode .dashboard-grid {
    grid-template-columns: 350px 1fr;
}

/* Terminal Container Styles */
.terminal-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 1rem;
}

.chart-wrapper {
    height: 200px;
    min-height: 200px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.price-scale {
    flex: 1;
    margin-top: 1rem;
    border-top: 1px dashed var(--border);
}

/* Fullview Mode */
body.fullview-mode .calc-sidebar,
body.fullview-mode .calc-analysis,
body.fullview-mode header {
    display: none !important;
}

body.fullview-mode .dashboard-grid {
    grid-template-columns: 1fr;
}

body.fullview-mode .viz-wrapper {
    height: 85vh !important;
}