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

/* ── Overlay ── */
.tpsl-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    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;
}

/* ── 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 */
@media (max-width: 768px) {
    .tp-edit-tpsl-btn .btn-label { display: none; }
    .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); }
    }
}