/* Trade Modal — extracted from styles.css 2026-05-17 (#19b). */
/* Loaded by index.html AFTER styles-bridge.css so cascade order is preserved. */

/* ============ Trade Modal ============ */
.trade-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
}

.trade-modal-content {
    background: #faf6f0;
    border-radius: 14px;
    width: 620px;
    max-width: 95vw;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow: 0 16px 56px rgba(0, 0, 0, 0.28);
    animation: modalSlideIn 0.2s ease-out;
    font-family: 'IBM Plex Mono', monospace;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.trade-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    border-bottom: 1px solid #e8e0d4;
}

.trade-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.trade-modal-header h3 {
    font-size: 13px;
    font-weight: 600;
    color: #5c5048;
    margin: 0;
    white-space: nowrap;
}

.close-modal {
    background: none;
    border: none;
    font-size: 18px;
    color: #a89984;
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}

.close-modal:hover {
    color: #3c3836;
    background: rgba(0,0,0,0.06);
}

/* ---- Buy/Sell Toggle ---- */
.trade-side-toggle {
    display: flex;
    border: none;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background: #f0ebe4;
    gap: 2px;
    padding: 2px;
}

.trade-side-btn {
    padding: 5px 16px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    color: #7c6f64;
    transition: all 0.2s;
    border-radius: 6px;
    font-family: 'IBM Plex Mono', monospace;
}

.trade-side-btn.buy.active {
    background: #a7c080;
    color: #2d353b;
}

.trade-side-btn.sell.active {
    background: #e67e80;
    color: #2d353b;
}

.trade-side-btn:hover:not(.active) {
    background: #e8e0d4;
}

/* ---- Market Token Trade Buttons ---- */
.market-tokens-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 12px;
    border-top: 1px solid #e8e0d4;
}

.market-tokens-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.market-token-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 8px;
    background: rgba(92, 80, 72, 0.06);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

.market-token-item:hover {
    background: rgba(92, 80, 72, 0.12);
}

.market-token-label {
    font-size: 11px;
    color: #5c5048;
    font-weight: 500;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.market-token-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.trade-btn.mini {
    padding: 2px 10px;
    font-size: 10px;
    min-width: 0;
}

.trade-modal-body {
    display: flex;
    gap: 0;
    padding: 0;
}

/* ---- Two-column layout ---- */
.trade-col-left {
    width: 240px;
    flex-shrink: 0;
    border-right: 1px solid #e8e0d4;
    display: flex;
    flex-direction: column;
}

.trade-col-right {
    flex: 1;
    min-width: 0;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.trade-market-info {
    margin-bottom: 0;
}

.trade-market-link {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #7c6f64;
    text-decoration: none;
    font-size: 11px;
    padding: 6px 10px;
    background: #f0ebe4;
    border-radius: 8px;
    border: 1px solid #e8e0d4;
    transition: all 0.2s;
    min-width: 0;
    overflow: hidden;
}

.trade-market-link:hover {
    background: #e8e0d4;
    border-color: #e8e0d4;
    color: #3c3836;
}

.trade-market-link #tradeMarketName {
    flex: 1;
    font-weight: 500;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.trade-market-link .link-icon {
    color: #a89984;
    font-size: 14px;
    flex-shrink: 0;
}

.trade-token-info {
    background: #f0ebe4;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 0;
}

.trade-token-name {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #5c5048;
    margin-bottom: 2px;
}

.trade-token-id {
    display: block;
    font-size: 9px;
    color: #a89984;
    word-break: break-all;
}

.price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
}

.price-label {
    color: #a89984;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.price-value {
    font-size: 13px;
    font-weight: 700;
    color: #3c3836;
}

.trade-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 10px;
    color: #a89984;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-with-suffix {
    display: flex;
    align-items: stretch;
    background: #fff;
    border: 1px solid #e8e0d4;
    border-radius: 8px;
    overflow: hidden;
    gap: 0;
}

.input-with-suffix:focus-within {
    border-color: #5c5048;
    box-shadow: 0 0 0 2px rgba(92, 80, 72, 0.12);
}

.input-with-suffix input {
    flex: 1;
    border: none;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 13px;
    background: transparent;
    outline: none;
    min-width: 0;
}

.input-with-suffix input:focus {
    background: transparent;
}

.input-suffix {
    display: flex;
    align-items: center;
    padding: 0 14px;
    background: #f0ebe4;
    color: #a89984;
    font-size: 11px;
    font-weight: 600;
    border-left: 1px solid #e8e0d4;
    white-space: nowrap;
}

/* MAX Button */
.max-btn {
    display: flex;
    align-items: center;
    padding: 0 16px;
    background: #5c5048;
    color: #f5ebe0;
    border: none;
    border-radius: 0;
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    margin: 0;
    transition: all 0.15s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-left: 1px solid #e8e0d4;
    font-family: 'IBM Plex Mono', monospace;
}

.max-btn:hover {
    background: #4a3f38;
}

.max-btn:active {
    background: #3c3228;
}

/* Balance display */
.trade-balance {
    background: #f0ebe4;
    border-radius: 8px;
    padding: 8px 10px;
}

.trade-balance .balance-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #3c3836;
    padding: 3px 0;
}

.trade-balance .balance-row span:last-child {
    font-weight: 600;
}

.trade-summary {
    background: #f0ebe4;
    border-radius: 8px;
    padding: 8px 10px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 12px;
}

.summary-row .profit {
    color: #4caf50;
    font-weight: 600;
}

/* Input mode toggle (Contracts / USD $) */
.size-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.input-mode-toggle {
    display: flex;
    background: #f0ebe4;
    border-radius: 6px;
    overflow: hidden;
    border: none;
    padding: 1px;
    gap: 1px;
}

.input-mode-btn {
    padding: 2px 8px;
    border: none;
    background: transparent;
    color: #7c6f64;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    letter-spacing: 0.3px;
    border-radius: 4px;
}

.input-mode-btn.active {
    background: #5c5048;
    color: #f5ebe0;
}

.input-mode-btn:hover:not(.active) {
    background: #e8e0d4;
}

/* Size hint (min, conversion) */
.size-hint {
    font-size: 10px;
    color: #a89984;
    min-height: 14px;
    line-height: 1.3;
}

.size-hint .calc-value {
    color: #5c5048;
    font-weight: 600;
}

/* Contracts row in summary */
#tradeContractsRow {
    font-size: 12px;
}

#tradeContractsCalc {
    font-weight: 600;
    color: #5c5048;
}

/* Earnings box */
.earnings-box {
    margin-top: 6px;
    padding: 8px 10px;
    background: #f0ebe4;
    border-radius: 8px;
    border: 1px solid #e8e0d4;
}

.earnings-title {
    font-size: 10px;
    font-weight: 600;
    color: #a89984;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.earnings-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    padding: 2px 0;
}

.earnings-row.win span:last-child {
    color: #4caf50;
    font-weight: 700;
}

.earnings-row.lose span:last-child {
    color: #e53935;
    font-weight: 600;
}

.earnings-row.roi span:last-child {
    color: #3c3836;
    font-weight: 700;
}

/* Tick size hint */
.tick-size-hint {
    font-size: 10px;
    color: #a08d72;
    padding: 0 2px;
    min-height: 0;
}

.trade-error {
    background: rgba(229,57,53,0.08);
    border: 1px solid rgba(229,57,53,0.2);
    border-radius: 8px;
    padding: 10px;
    color: #e53935;
    font-size: 11px;
}

/* Geoblock heads-up — amber, not red: the region is restricted by
   Polymarket, but close-only regions may still close positions. */
.trade-geo-warning {
    background: rgba(255,152,0,0.08);
    border: 1px solid rgba(255,152,0,0.25);
    border-radius: 8px;
    padding: 10px;
    color: #ef8b00;
    font-size: 11px;
}

.trade-wallet-notice {
    background: #f0ebe4;
    border: 1px solid #e8e0d4;
    border-radius: 8px;
    padding: 8px 10px;
    color: #7c6f64;
    font-size: 10px;
    line-height: 1.4;
}

.trade-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.trade-actions button {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.cancel-btn {
    background: #f0ebe4;
    color: #7c6f64;
    border-radius: 8px;
}

.cancel-btn:hover {
    background: #e8e0d4;
}

.connect-wallet-trade-btn {
    background: #5c5048;
    color: #f5ebe0;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.connect-wallet-trade-btn:hover {
    background: #3a3228;
}

.approve-btn {
    background: #5c5048;
    color: #f5ebe0;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    flex: 1;
    transition: all 0.2s ease;
    font-family: 'IBM Plex Mono', monospace;
}

.approve-btn:hover {
    background: #4a3f38;
    transform: translateY(-1px);
}

.approve-btn:disabled {
    background: #9a8e84;
    cursor: wait;
}

.confirm-btn {
    background: #a7c080;
    color: #2d353b;
    border-radius: 8px;
    font-weight: 700;
}

.confirm-btn:hover {
    filter: brightness(1.08);
}

.confirm-btn.sell {
    background: #e67e80;
    color: #2d353b;
}

.confirm-btn.sell:hover {
    filter: brightness(1.08);
}

.confirm-btn:disabled {
    background: #9a8e84;
    cursor: not-allowed;
}

.confirm-btn.insufficient {
    background: #e67e80;
    color: #2d353b;
    opacity: 0.9;
}

/* Trade modal — Deposit / Transfer buttons */
.trade-fund-actions {
    display: flex;
    gap: 6px;
    flex: 1;
}

.trade-deposit-btn,
.trade-transfer-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.trade-deposit-btn {
    background: #a7c080;
    color: #2d353b;
}
.trade-deposit-btn:hover {
    filter: brightness(1.08);
}

.trade-transfer-btn {
    background: #d4a46a;
    color: #2d353b;
    border: none;
}
.trade-transfer-btn:hover {
    filter: brightness(1.08);
}

.trade-status {
    text-align: center;
    padding: 16px;
}

.status-icon {
    font-size: 28px;
    margin-bottom: 8px;
}

.status-text {
    font-size: 11px;
    color: #5c5048;
}

.trade-status.success .status-icon {
    color: #4caf50;
}

.trade-status.error .status-icon {
    color: #e67e80;
}

/* ============ ORDERBOOK STYLES ============ */

.trade-price-info {
    padding: 10px 12px;
    background: #f5f0e8;
    margin-bottom: 0;
}

.price-bba {
    display: flex;
    gap: 8px;
}

.price-bba .price-row {
    flex: 1;
}

.price-row.main-price {
    border-bottom: 1px solid #e5dcc8;
    padding-bottom: 6px;
    margin-bottom: 4px;
}

.price-row.main-price .price-value {
    font-size: 16px;
    color: #5c5048;
}

.price-row.small {
    padding: 4px 0;
}

.price-row.small .price-label,
.price-row.small .price-value {
    font-size: 10px;
}

.price-value.bid {
    color: #6a9a3a;
}

.price-value.ask {
    color: #e67e80;
}

.orderbook-container {
    background: #f5f0e8;
    border-radius: 0 0 0 10px;
    padding: 8px;
    flex: 1;
    overflow-y: auto;
    min-height: 200px;
}

.orderbook-loading {
    color: #a89984;
    font-size: 11px;
    text-align: center;
    padding: 20px;
    background: #f5f0e8;
}

.orderbook {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
}

.orderbook-asks,
.orderbook-bids {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.orderbook-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 3px 6px;
    position: relative;
    border-radius: 3px;
    cursor: pointer;
    transition: background 0.1s;
}

.orderbook-row:hover {
    background: rgba(92, 80, 72, 0.08);
}

.orderbook-bar {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.orderbook-row.ask .orderbook-bar {
    background: #e67e80;
    opacity: 0.25;
}

.orderbook-row.bid .orderbook-bar {
    background: #a7c080;
    opacity: 0.35;
}

.orderbook-price {
    position: relative;
    z-index: 1;
    font-weight: 600;
    min-width: 45px;
}

.orderbook-row.ask .orderbook-price {
    color: #c9585a;
}

.orderbook-row.bid .orderbook-price {
    color: #6a9a3a;
}

.orderbook-size {
    position: relative;
    z-index: 1;
    color: #a89984;
    font-weight: 500;
    flex: 1;
    text-align: center;
}

.orderbook-spread {
    text-align: center;
    padding: 6px;
    color: #a89984;
    font-size: 10px;
    background: #faf6f0;
    border-radius: 4px;
    margin: 4px 0;
}

.orderbook-header {
    display: flex;
    justify-content: space-between;
    padding: 4px 6px 6px;
    font-size: 9px;
    font-weight: 600;
    color: #a89984;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #e5dcc8;
    margin-bottom: 4px;
}

.orderbook-total {
    position: relative;
    z-index: 1;
    color: #a89984;
    font-weight: 500;
    text-align: right;
    min-width: 50px;
}

/* Price flash animation */
@keyframes priceFlash {
    0% { background: rgba(255, 255, 0, 0.3); }
    100% { background: transparent; }
}

.price-flash {
    animation: priceFlash 0.3s ease-out;
}

/* ============ ORDER TYPE TOGGLE ============ */

.order-type-toggle {
    display: flex;
    background: #faf6f0;
    border-radius: 6px;
    padding: 2px;
    margin-bottom: 4px;
}

.order-type-btn {
    flex: 1;
    padding: 6px 10px;
    border: none;
    border-radius: 5px;
    background: transparent;
    color: #a89984;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.order-type-btn:hover {
    color: #5c5048;
}

.order-type-btn.active {
    background: white;
    color: #5c5048;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.liquidity-info {
    font-size: 10px;
    color: #a89984;
    margin-top: 4px;
    padding: 4px 8px;
    background: #f5f0e8;
    border-radius: 4px;
}

.liquidity-info span {
    color: #5c5048;
    font-weight: 600;
}


/* ─── Trade modal — mobile overrides (#19e/f) ─────────────────────────── */
/* Moved here from main styles.css MOBILE LAYOUT block. */
@media (max-width: 768px) {
    .trade-modal {
        align-items: flex-end !important;
    }

    .trade-modal-content {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 16px 16px 0 0 !important;
        max-height: 80vh;
        overflow-y: auto;
    }

    .trade-modal-body {
        flex-direction: column !important;
    }

    .trade-col-left, .trade-col-right {
        width: 100% !important;
    }
}
