/* ==========================================================================
   Premium Dark Theme - Trader Han's Box Trading (Web)
   ========================================================================== */

@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css');

:root {
    /* Color Palette */
    --bg-main: #0f172a;
    --bg-panel: #1e293b;
    --bg-input: #334155;
    --bg-hover: #475569;
    --border-color: #475569;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #3b82f6;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --sidebar-width: 20vw;
    /* Approx 20% of total screen */
    --header-height: 60px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-size: 13px;
    height: 100vh;
    overflow: hidden;
}

/* ==========================================================================
   Layout (Split Screen)
   ========================================================================== */
.split-screen-layout {
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

.left-chart-placeholder {
    width: 40%;
    /* User requested 40% */
    background-color: #131722;
    flex-shrink: 0;
    position: relative;
    border-right: 1px solid var(--border-color);
}

.chart-resizer {
    width: 8px;
    cursor: col-resize;
    background-color: var(--bg-main);
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    z-index: 999;
    transition: background 0.2s;
    flex-shrink: 0;
}

.chart-resizer:hover {
    background: var(--accent-color);
}

.resizer {
    width: 8px;
    /* Width of the sidebar resizer */
    cursor: col-resize;
    background-color: var(--bg-main);
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    z-index: 999;
    transition: background 0.2s;
    flex-shrink: 0;
}

.resizer:hover {
    background-color: var(--accent-color);
}

.right-ui-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 400px;
    height: 100%;
    background-color: var(--bg-main);
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Header */
.top-header {
    height: var(--header-height);
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    flex-shrink: 0;
}

.header-left,
.header-center,
.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.app-logo-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    width: 36px;
    height: 36px;
}

.logo-text-group {
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1.1;
}

.logo-title {
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.logo-subtitle {
    font-size: 0.65rem;
    color: var(--accent-color);
    letter-spacing: 2px;
    font-weight: 600;
}

.header-status-panel {
    background: rgba(0, 0, 0, 0.2);
    padding: 4px 12px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    display: flex;
    gap: 15px;
    align-items: center;
}

.status-badge {
    font-weight: 600;
    font-size: 0.85rem;
}

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

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

.time-display {
    font-family: 'Roboto Mono', monospace;
    color: var(--accent-color);
    font-weight: 700;
    font-size: 0.9rem;
}

/* Quick Settings */
.quick-settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 2px;
}

.quick-settings-row label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.quick-settings-row input[type="checkbox"] {
    accent-color: var(--accent-color);
}

.btn {
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-primary);
    cursor: pointer;
    font-weight: 600;
}

.btn:hover {
    background: var(--bg-hover);
}

.btn-start {
    border-color: var(--success-color);
    color: var(--success-color);
    background: rgba(16, 185, 129, 0.1);
}

.btn-stop {
    border-color: var(--danger-color);
    color: var(--danger-color);
    background: rgba(239, 68, 68, 0.1);
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
    border: none;
}

/* Main App Layout */
.app-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.sidebar {
    width: var(--sidebar-width);
    background-color: #162032;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 10px;
    gap: 10px;
    flex-shrink: 0;
}

.content-area {
    flex: 1;
    background-color: var(--bg-main);
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}



/* Components */
.panel-section {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
}

.panel-section h3 {
    margin: 0 0 10px 0;
    font-size: 0.85rem;
    color: var(--accent-color);
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
}

/* Status Cards */
.status-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.status-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px;
}

.status-card.border-green {
    border: 4px solid var(--success-color);
}

.status-card.border-red {
    border: 4px solid var(--danger-color);
}

.card-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--accent-color);
}

.card-row {
    font-size: 0.8rem;
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    color: var(--text-secondary);
}

/* Position Cards */
.positions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.position-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.position-card.long {
    border-left: 8px solid var(--success-color);
}

.position-card.short {
    border-left: 8px solid var(--danger-color);
}

.position-card.active {
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
}

.position-card.border-green {
    border: 4px solid var(--success-color) !important;
}

.position-card.border-red {
    border: 4px solid var(--danger-color) !important;
}

.p-card-header {
    background: #0f172a;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.p-direction {
    font-weight: 700;
    font-size: 1rem;
}

.long .p-direction {
    color: var(--success-color);
}

.short .p-direction {
    color: var(--danger-color);
}

.p-status {
    font-size: 1rem;
    padding: 4px 12px;
    border-radius: 4px;
    background: var(--bg-input);
    color: var(--text-secondary);
    font-weight: 600;
}

.p-status.active {
    color: white;
    background: var(--success-color);
}

.short .p-status.active {
    background: var(--danger-color);
}

/* Position Card Body - Horizontal Layout */
.p-card-body {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    /* Spread items horizontally */
    align-items: center;
}

.p-row {
    display: flex;
    flex-direction: column;
    /* Label on top, Value on bottom */
    align-items: center;
    gap: 5px;
    margin-bottom: 0;
}

.p-row span:first-child {
    font-size: 0.85rem;
    color: #94a3b8;
}

.p-row span:last-child {
    font-size: 1.2rem;
    /* Big Value */
    font-weight: 700;
    color: white;
}

/* Highlight Profit */
.p-row.highlight span:last-child {
    font-size: 1.4rem;
}

.p-profit.profit {
    color: var(--success-color);
    font-weight: bold;
}

.p-profit.loss {
    color: var(--danger-color);
    font-weight: bold;
}

/* Manual Exit Button */
.btn-manual-exit {
    background: #ef4444;
    color: white;
    border: none;
    padding: 6px 16px;
    /* Bigger button */
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 700;
    transition: background 0.2s;
}

.btn-manual-exit:hover {
    background: #dc2626;
}

/* ==========================================================================
   Webhook Setup Grid (Refined Desktop Parity)
   ========================================================================== */
.webhook-config-section h2,
.active-positions-section h2,
.trading-results-section h2 {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: var(--accent-color);
    display: flex;
    align-items: center;
    gap: 6px;
}

.webhook-config-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px;
    width: 100%;
}

.webhook-config-card {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    box-shadow: var(--shadow-sm);
    min-width: 0 !important;
    overflow: hidden;
}

.webhook-card-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Input Rows (Horizontal: Label | Input) */
.input-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 26px;
    margin-bottom: 4px;
}

.input-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    width: 100px;
    flex-shrink: 0;
}

.wh-input,
.wh-input-select {
    flex: 1;
    min-width: 0 !important;
    height: 26px;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0 8px;
    color: var(--text-primary);
    font-size: 0.8rem;
    outline: none;
    box-shadow: inset 0 1px 2px 0 rgb(0 0 0 / 0.1);
}

.wh-input:focus {
    border-color: var(--accent-color);
}

/* Checkboxes & Small Inputs */
.flex-center-gap {
    display: flex;
    align-items: center;
    gap: 6px;
}

.wh-checkbox {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-color);
    cursor: pointer;
}

.wh-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-color);
    cursor: pointer;
    margin-left: 5px;
    vertical-align: middle;
}

.label-xs {
    font-size: 0.7rem;
    color: #94a3b8;
}

.input-xs {
    width: 60px !important;
    flex: none !important;
}

/* Sidebar Fixes for Density */
.quick-settings-row {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 10px !important;
    font-size: 0.8rem;
    margin-top: 5px;
}

.market-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 5px !important;
    margin-top: 5px;
}

.market-item {
    padding: 5px !important;
    text-align: center;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.market-label {
    font-size: 0.7rem !important;
    color: #94a3b8;
}

.market-value {
    font-size: 0.9rem !important;
    font-weight: 700;
    color: #f8fafc;
}

/* Log Tabs */
.log-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 5px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 4px;
}

.log-tab {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 4px 8px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
}

.log-tab.active {
    color: var(--accent-color);
    border-bottom: 2px solid var(--accent-color);
}

.log-list {
    font-family: 'Roboto Mono', monospace;
    font-size: 0.7rem;
}


/* History Table */
.trading-history-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.trading-history-table th {
    background: #1e293b;
    border-bottom: 1px solid var(--border-color);
    padding: 8px;
    text-align: left;
    color: var(--text-secondary);
}

.trading-history-table td {
    border-bottom: 1px solid #334155;
    padding: 8px;
    color: var(--text-secondary);
}

/* Webhook Send History (Inside Config Cards) */
.history-list {
    min-height: 40px;
    border-top: 1px solid var(--border-color);
    padding: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.2);
    margin-top: 8px;
    border-radius: 4px;
    max-height: 100px;
    overflow-y: auto;
}

.history-list:empty::before {
    content: "No recent history.";
    color: #475569;
    font-style: italic;
    display: block;
    text-align: center;
    padding: 4px;
}

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

.input-url-header {
    width: 200px;
}

/* Logs */
.log-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 200px;
}

.log-list {
    flex: 1;
    overflow-y: auto;
    background: #000;
    padding: 5px;
    border-radius: 4px;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.75rem;
}

.webhook-entry {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid #333;
    padding: 2px 0;
}

.webhook-entry .time {
    color: #64748b;
}

.webhook-entry .event {
    color: #f8fafc;
    font-weight: bold;
}

.webhook-entry .chart {
    color: var(--accent-color);
}

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

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

/* Scrollbars */
::-webkit-scrollbar {
    width: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}/* ==========================================================================
   Custom Modal Dialogs (Centered)
   ========================================================================== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-dialog {
    background: var(--bg-panel);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 24px;
    min-width: 320px;
    max-width: 500px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.modal-message {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-btn {
    padding: 8px 20px;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-btn-primary {
    background: var(--accent-color);
    color: white;
}

.modal-btn-primary:hover {
    background: #2563eb;
}

.modal-btn-danger {
    background: var(--danger-color);
    color: white;
}

.modal-btn-danger:hover {
    background: #dc2626;
}

.modal-btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
}

.modal-btn-secondary:hover {
    background: var(--bg-hover);
}
