/* ══════════════════════════════════════════════
   TP/SL Edit Modal
   ══════════════════════════════════════════════ */

/* ── Overlay ── */
.tpsl-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, 0.88);
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: tpslFadeIn 0.18s ease;
}
.tpsl-modal-overlay.open {
    display: flex;
}

@keyframes tpslFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Modal box ── */
.tpsl-modal {
    background: linear-gradient(160deg, #1a1f3a 0%, #141828 100%);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 20px;
    width: 100%;
    max-width: 420px;
    box-shadow:
        0 32px 64px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(255, 255, 255, 0.04) inset;
    animation: tpslSlideUp 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

@keyframes tpslSlideUp {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* ── Header ── */
.tpsl-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 22px 22px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.tpsl-modal-title-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tpsl-modal-title {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tpsl-modal-title svg {
    color: var(--gold, #e8b84b);
    flex-shrink: 0;
}

.tpsl-modal-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
}

.tpsl-meta-symbol {
    font-size: 0.78rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.9);
    letter-spacing: 0.03em;
}

.tpsl-meta-side {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.tpsl-meta-side.buy  { background: rgba(38, 166, 154, 0.15); color: #26a69a; }
.tpsl-meta-side.sell { background: rgba(239, 83,  80, 0.15); color: #ef5350; }

.tpsl-meta-entry {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.4);
}

.tpsl-modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.5);
    transition: all 0.15s;
    flex-shrink: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.tpsl-modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}
.tpsl-modal-close svg { pointer-events: none; }

/* ── Body ── */
.tpsl-modal-body {
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ── Input rows ── */
.tpsl-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.tpsl-field-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.tpsl-field-label span {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}
.tpsl-field.tp .tpsl-field-label span { color: #26a69a; }
.tpsl-field.sl .tpsl-field-label span { color: #ef5350; }

.tpsl-clear-btn {
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.3);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    transition: color 0.15s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.tpsl-clear-btn:hover { color: rgba(255, 255, 255, 0.7); }

.tpsl-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.tpsl-input-wrap svg {
    position: absolute;
    left: 12px;
    color: rgba(255, 255, 255, 0.25);
    pointer-events: none;
    flex-shrink: 0;
}

.tpsl-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 11px 12px 11px 36px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #fff;
    outline: none;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
    -webkit-appearance: none;
    appearance: none;
}
.tpsl-input::placeholder { color: rgba(255, 255, 255, 0.2); }

.tpsl-field.tp .tpsl-input:focus {
    border-color: rgba(38, 166, 154, 0.6);
    background: rgba(38, 166, 154, 0.06);
    box-shadow: 0 0 0 3px rgba(38, 166, 154, 0.1);
}
.tpsl-field.sl .tpsl-input:focus {
    border-color: rgba(239, 83, 80, 0.6);
    background: rgba(239, 83, 80, 0.06);
    box-shadow: 0 0 0 3px rgba(239, 83, 80, 0.1);
}
.tpsl-input.input-error {
    border-color: rgba(239, 83, 80, 0.7) !important;
    box-shadow: 0 0 0 3px rgba(239, 83, 80, 0.12) !important;
}
.tpsl-input.input-locked,
.tpsl-input:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: rgba(255, 80, 80, 0.04);
    border-color: rgba(255, 80, 80, 0.15);
}

/* ── Hint line below input ── */
.tpsl-hint {
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.3);
    padding-left: 2px;
    min-height: 14px;
    transition: color 0.15s;
}
.tpsl-hint.error { color: #ef5350; }
.tpsl-hint.ok    { color: #26a69a; }

/* ── Divider ── */
.tpsl-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.05);
    margin: 0 -22px;
}

/* ── Footer ── */
.tpsl-modal-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 22px 20px;
}

.tpsl-btn-cancel {
    flex: 1;
    height: 44px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.tpsl-btn-cancel:hover {
    background: rgba(255, 255, 255, 0.09);
    color: rgba(255, 255, 255, 0.9);
}

.tpsl-btn-save {
    flex: 2;
    height: 44px;
    background: linear-gradient(135deg, #e8b84b 0%, #d4961e 100%);
    border: none;
    border-radius: 10px;
    color: #1a1209;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    letter-spacing: 0.01em;
}
.tpsl-btn-save:hover {
    background: linear-gradient(135deg, #f0c560 0%, #e0a830 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(232, 184, 75, 0.3);
}
.tpsl-btn-save:active { transform: translateY(0); }
.tpsl-btn-save:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}
.tpsl-btn-save svg { pointer-events: none; }

/* Loading spinner inside save button */
.tpsl-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(26, 18, 9, 0.3);
    border-top-color: #1a1209;
    border-radius: 50%;
    animation: tpslSpin 0.7s linear infinite;
    display: none;
}
.tpsl-btn-save.loading .tpsl-spinner { display: block; }
.tpsl-btn-save.loading .tpsl-btn-text { display: none; }

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

/* ── Success flash ── */
.tpsl-success-flash {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(38, 166, 154, 0.12);
    border: 1px solid rgba(38, 166, 154, 0.25);
    border-radius: 8px;
    color: #26a69a;
    font-size: 0.8rem;
    font-weight: 600;
    margin: 0 22px 16px;
}
.tpsl-success-flash.visible { display: flex; }

/* ── Edit button in table ── */
.tp-edit-tpsl-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: rgba(232, 184, 75, 0.08);
    color: var(--gold, #e8b84b);
    border: 1px solid rgba(232, 184, 75, 0.2);
    padding: 3px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.68rem;
    font-weight: 600;
    transition: all 0.15s;
    white-space: nowrap;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.tp-edit-tpsl-btn:hover {
    background: rgba(232, 184, 75, 0.16);
    border-color: rgba(232, 184, 75, 0.4);
}
.tp-edit-tpsl-btn svg { pointer-events: none; flex-shrink: 0; }

/* Hide text on mobile — show icon only (except inside position cards) */
@media (max-width: 768px) {
    .tp-edit-tpsl-btn .btn-label { display: none; }
    .tp-pos-card .tp-edit-tpsl-btn .btn-label { display: inline; }
    .tp-edit-tpsl-btn {
        padding: 4px 6px;
        border-radius: 4px;
    }

    /* Larger tap target for close/edit buttons on mobile */
    .tp-close-btn,
    .tp-edit-tpsl-btn {
        min-width: 32px;
        min-height: 32px;
    }

    .tpsl-modal {
        max-width: 100%;
        border-radius: 18px 18px 0 0;
        margin-top: auto;
    }

    .tpsl-modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    @keyframes tpslSlideUp {
        from { opacity: 0; transform: translateY(100%); }
        to   { opacity: 1; transform: translateY(0); }
    }
}

/* ══════════════════════════════════════════════
   TP/SL Edit Locked Dialog
   ══════════════════════════════════════════════ */

.tpsl-locked-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100000;
    background: rgba(0, 0, 0, 0.87);
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.tpsl-locked-overlay.open {
    display: flex;
}

.tpsl-locked-modal {
    background: linear-gradient(160deg, #1a1f3a 0%, #141828 100%);
    border: 1px solid rgba(255, 100, 100, 0.2);
    border-radius: 20px;
    padding: 32px 28px 28px;
    max-width: 340px;
    width: 100%;
    text-align: center;
    box-shadow:
        0 32px 72px rgba(0, 0, 0, 0.65),
        0 0 0 1px rgba(255, 255, 255, 0.04) inset;
    animation: tpslLockedPop 0.26s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes tpslLockedPop {
    from { opacity: 0; transform: scale(0.88) translateY(10px); }
    to   { opacity: 1; transform: scale(1)    translateY(0); }
}

.tpsl-locked-icon-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 18px;
}
.tpsl-locked-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(255, 80, 80, 0.14), rgba(200, 60, 60, 0.08));
    border: 1.5px solid rgba(255, 80, 80, 0.28);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ff6060;
    box-shadow: 0 0 28px rgba(255, 80, 80, 0.12);
}

.tpsl-locked-badge {
    display: inline-block;
    background: rgba(255, 80, 80, 0.1);
    border: 1px solid rgba(255, 80, 80, 0.22);
    color: #ff8080;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 3px 11px;
    border-radius: 20px;
    margin-bottom: 14px;
}

.tpsl-locked-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-0, #fff);
    margin: 0 0 10px;
    letter-spacing: -0.01em;
}

.tpsl-locked-desc {
    font-size: 0.85rem;
    color: var(--text-2, #999);
    line-height: 1.65;
    margin: 0 0 24px;
}

.tpsl-locked-btn {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 700;
    background: linear-gradient(135deg, #ff4d4d, #c93030);
    color: #fff;
    transition: opacity 0.18s, transform 0.14s;
}
.tpsl-locked-btn:hover  { opacity: 0.86; transform: translateY(-1px); }
.tpsl-locked-btn:active { opacity: 1;    transform: translateY(0); }

/* ══════════════════════════════════════════════
   R:R Ratio Badge & Auto-fill
   ══════════════════════════════════════════════ */

/* Badge in modal header title */
.tpsl-rr-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: linear-gradient(135deg, rgba(232, 184, 75, 0.15), rgba(180, 130, 30, 0.08));
    border: 1px solid rgba(232, 184, 75, 0.35);
    color: #e8b84b;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    white-space: nowrap;
}
.tpsl-rr-badge::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #e8b84b;
    box-shadow: 0 0 6px rgba(232, 184, 75, 0.8);
    animation: tpslRRPulse 1.8s ease-in-out infinite;
    flex-shrink: 0;
}
@keyframes tpslRRPulse {
    0%, 100% { opacity: 1;   transform: scale(1); }
    50%       { opacity: 0.4; transform: scale(0.7); }
}

/* Label row: label text + "auto" tag side by side */
.tpsl-label-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* "auto" tag next to TP or SL label */
.tpsl-rr-auto-tag {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #e8b84b;
    background: rgba(232, 184, 75, 0.12);
    border: 1px solid rgba(232, 184, 75, 0.3);
    padding: 1px 5px;
    border-radius: 4px;
}

/* Input gold tint when auto-filled by R:R */
.tpsl-input.rr-auto-filled {
    border-color: rgba(232, 184, 75, 0.45) !important;
    background: rgba(232, 184, 75, 0.05) !important;
    box-shadow: 0 0 0 3px rgba(232, 184, 75, 0.08) !important;
}