/* ═══════════════ Positions Widget — Open Positions & Orders ═══════════════
   Styles for: position cards, PNL colors, leverage badges, TP/SL inline edit,
   order rows, tab switching, responsive mobile layout, close/cancel buttons
   ═══════════════════════════════════════════════════════════════════════════ */
.positions-table {
    width: 100%;
    font-size: 11px;
    border-collapse: collapse;
}
.positions-table thead th {
    padding: 6px 8px;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-align: left;
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}
.positions-table tbody tr {
    transition: background var(--transition);
}
.positions-table tbody tr:hover {
    background: var(--bg-hover);
}
.positions-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 11px;
}
.positions-table .col-symbol {
    font-family: var(--font);
    font-weight: 600;
    color: var(--text-primary);
}
.positions-table .col-actions {
    text-align: right;
}

/* Position action buttons */
.pos-btn {
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    margin-left: 3px;
}
.pos-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.pos-btn.close-btn:hover {
    background: var(--red-bg);
    color: var(--red);
    border-color: var(--red-border);
}

/* TP/SL inline edit */
.tpsl-value {
    cursor: pointer;
    padding: 1px 4px;
    border-radius: 3px;
    transition: background var(--transition);
}
.tpsl-value:hover {
    background: var(--bg-hover);
}
.tpsl-input {
    width: 80px;
    padding: 2px 4px;
    font-size: 11px;
    font-family: var(--font-mono);
    background: var(--bg-primary);
    border: 1px solid var(--accent);
    border-radius: 3px;
    color: var(--text-primary);
    outline: none;
}

/* Orders tab */
.orders-table {
    width: 100%;
    font-size: 11px;
    border-collapse: collapse;
}
.orders-table thead th {
    padding: 6px 8px;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-align: left;
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.orders-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 11px;
}

/* ═══════════════ MOBILE — Card Layout ═══════════════ */

/* Mobile positions card list */
.positions-mobile-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
}

/* Position card */
.pos-card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    cursor: pointer;
    transition: background var(--transition);
}
.pos-card:active {
    background: var(--bg-hover);
}

/* Card header: symbol + PnL */
.pos-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.pos-card-symbol {
    display: flex;
    align-items: center;
    gap: 6px;
}
.pos-card-name {
    font-family: var(--font);
    font-weight: 700;
    font-size: 15px;
    color: var(--text-primary);
}
.pos-card-leverage {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--surface-2);
    padding: 1px 5px;
    border-radius: 4px;
}

/* Card data grid: 2 columns */
.pos-card-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 16px;
    margin-bottom: 10px;
}
.pos-card-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.pos-card-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.pos-card-value {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-primary);
}
.pos-card-value small {
    font-size: 10px;
    color: var(--text-muted);
    margin-left: 2px;
}
.pos-card-field .edit-icon {
    font-size: 10px;
    opacity: 0.5;
    margin-left: 3px;
}

/* TP/SL fields as tappable areas */
.pos-card-field.tp-cell,
.pos-card-field.sl-cell {
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    margin: -4px -6px;
    transition: background var(--transition);
}
.pos-card-field.tp-cell:active,
.pos-card-field.sl-cell:active {
    background: var(--bg-hover);
}

/* Card actions */
.pos-card-actions {
    padding-top: 8px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
}

/* Close button — mobile confirm state */
.close-btn.close-confirm {
    background: var(--red) !important;
    color: #fff !important;
    border-color: var(--red) !important;
    animation: pulse-confirm 0.6s ease-in-out infinite alternate;
}
@keyframes pulse-confirm {
    from { opacity: 1; }
    to { opacity: 0.7; }
}

/* TP/SL edit row — mobile */
.tpsl-edit-mobile {
    padding: 10px 12px;
    margin: 0 8px 8px;
    background: var(--surface-1);
    border: 1px solid var(--accent);
    border-radius: 8px;
}

@media (max-width: 768px) {
    /* Desktop table hidden on mobile (JS renders .positions-mobile-list instead) */
    .positions-table {
        display: none;
    }

    /* Pozisyon aksiyon butonları */
    .pos-btn {
        padding: 10px 18px;
        font-size: 13px;
        min-height: 40px;
        border-radius: 6px;
        font-weight: 600;
    }
    .pos-btn.close-btn {
        border-color: var(--red-border);
        color: var(--red);
    }

    /* TP/SL inline edit */
    .tpsl-input {
        width: 100%;
        padding: 8px 10px;
        font-size: 16px;
        min-height: 40px;
        border-radius: 6px;
    }

    /* Orders tablosu da kart */
    .orders-table thead {
        display: none;
    }
    .orders-table {
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding: 8px;
    }
    .orders-table tbody {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    .orders-table tbody tr {
        display: flex;
        flex-wrap: wrap;
        gap: 6px 12px;
        padding: 10px 12px;
        border: 1px solid var(--border);
        border-radius: 8px;
        background: var(--surface-1);
    }
    .orders-table td {
        display: inline-flex;
        padding: 0;
        border-bottom: none;
        font-size: 12px;
    }

    /* History table mobile */
    .history-table thead {
        display: none;
    }
    .history-table {
        display: flex;
        flex-direction: column;
        gap: 0;
        padding: 0;
    }
    .history-table tbody {
        display: flex;
        flex-direction: column;
        gap: 0;
    }
    .history-table tbody tr {
        display: none;
    }
}

/* ═══════════════ History Tab — Trade History ═══════════════ */

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
}
.history-symbol {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.3px;
}

/* History desktop table */
.history-table {
    width: 100%;
    font-size: 11px;
    border-collapse: collapse;
}
.history-table thead th {
    padding: 6px 8px;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-align: left;
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}
.history-table td {
    padding: 5px 8px;
    border-bottom: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 11px;
    white-space: nowrap;
}
.history-table tbody tr {
    transition: background var(--transition);
}
.history-table tbody tr:hover {
    background: var(--bg-hover);
}

/* History mobile card */
.history-card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
}
.history-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.history-card-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 16px;
}

/* History mode toggle (Coin / Tümü) */
.history-mode-toggle {
    display: flex;
    align-items: center;
    gap: 2px;
    background: var(--surface-2);
    border-radius: 6px;
    padding: 2px;
}
.history-mode-btn {
    background: none;
    border: none;
    border-radius: 5px;
    padding: 3px 10px;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    white-space: nowrap;
}
.history-mode-btn.active {
    background: var(--accent);
    color: #fff;
}
.history-mode-btn:hover:not(.active) {
    background: var(--bg-hover);
    color: var(--text-primary);
}
