/* ═══════════════════════════════════════════════════════════════
   NQT EXCHANGE — Styles
   ═══════════════════════════════════════════════════════════════
   Uses QuickTools design tokens: tokens.css → theme-light/dark.css
   Mobile-first, dark mode native
   ═══════════════════════════════════════════════════════════════ */

/* ── Variables ── */
.nqt-exchange {
    --ex-green: #10B981;
    --ex-green-bg: rgba(16, 185, 129, 0.08);
    --ex-green-text: #059669;
    --ex-red: #EF4444;
    --ex-red-bg: rgba(239, 68, 68, 0.08);
    --ex-red-text: #DC2626;
    --ex-ob-row-h: 28px;
}

[data-theme="dark"] .nqt-exchange {
    --ex-green-text: #34D399;
    --ex-red-text: #F87171;
    --ex-green-bg: rgba(16, 185, 129, 0.12);
    --ex-red-bg: rgba(239, 68, 68, 0.12);
}

/* ═══ Header Stats ═══ */
.nqt-ex-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-5);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-4);
}

.nqt-ex-pair {
    display: flex;
    align-items: baseline;
    gap: var(--space-3);
}

.nqt-ex-pair__name {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--text-primary);
}

.nqt-ex-pair__price {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

.nqt-ex-pair__change {
    font-size: var(--font-size-sm);
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
}

.nqt-ex-pair__change.positive {
    color: var(--ex-green-text);
    background: var(--ex-green-bg);
}

.nqt-ex-pair__change.negative {
    color: var(--ex-red-text);
    background: var(--ex-red-bg);
}

.nqt-ex-stats {
    display: flex;
    gap: var(--space-6);
}

.nqt-ex-stat__label {
    display: block;
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nqt-ex-stat__value {
    font-size: var(--font-size-sm);
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

/* ═══ Main Grid ═══ */
.nqt-ex-grid {
    display: grid;
    grid-template-columns: 260px 1fr 220px;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

@media (max-width: 1023px) {
    .nqt-ex-grid {
        grid-template-columns: 1fr;
    }
    .nqt-ex-orderbook { order: 2; }
    .nqt-ex-form { order: 1; }
    .nqt-ex-trades { order: 3; }
}

.nqt-ex-section-title {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 var(--space-3);
    padding: 0 var(--space-2);
}

/* ═══ Order Book ═══ */
.nqt-ex-orderbook {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    overflow: hidden;
}

.nqt-ex-ob-header {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--space-2);
    padding: 0 var(--space-2) var(--space-2);
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 1px solid var(--border-light);
}

.nqt-ex-ob-header span:last-child,
.nqt-ex-ob-row span:last-child {
    text-align: right;
}

.nqt-ex-ob-asks,
.nqt-ex-ob-bids {
    max-height: 200px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.nqt-ex-ob-asks {
    display: flex;
    flex-direction: column-reverse;
}

.nqt-ex-ob-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--space-2);
    padding: 2px var(--space-2);
    height: var(--ex-ob-row-h);
    align-items: center;
    font-size: var(--font-size-xs);
    font-family: var(--font-mono);
    position: relative;
    cursor: pointer;
    border-radius: 3px;
    transition: background var(--transition-fast);
}

.nqt-ex-ob-row:hover {
    background: var(--bg-tertiary);
}

.nqt-ex-ob-row::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    border-radius: 3px;
    z-index: 0;
    transition: width var(--transition-base);
}

.nqt-ex-ob-row--ask::before {
    background: var(--ex-red-bg);
}

.nqt-ex-ob-row--bid::before {
    background: var(--ex-green-bg);
}

.nqt-ex-ob-row span {
    position: relative;
    z-index: 1;
}

.nqt-ex-ob-row--ask .nqt-ex-ob-price { color: var(--ex-red-text); }
.nqt-ex-ob-row--bid .nqt-ex-ob-price { color: var(--ex-green-text); }

/* Spread */
.nqt-ex-ob-spread {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) 0;
    border-top: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
    margin: var(--space-1) 0;
}

.nqt-ex-ob-spread__price {
    font-size: var(--font-size-base);
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

.nqt-ex-ob-spread__pct {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
}

.nqt-ex-ob-loading {
    padding: var(--space-6);
    text-align: center;
    color: var(--text-tertiary);
    font-size: var(--font-size-sm);
}

/* ═══ Trade Form ═══ */
.nqt-ex-form {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
}

/* Side Tabs (Buy / Sell) */
.nqt-ex-side-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.nqt-ex-side-tab {
    padding: var(--space-2) var(--space-4);
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.nqt-ex-side-tab--buy.active {
    background: var(--ex-green);
    color: white;
}

.nqt-ex-side-tab--sell.active {
    background: var(--ex-red);
    color: white;
}

/* Type Tabs (Limit / Market / Floor) */
.nqt-ex-type-tabs {
    display: flex;
    gap: var(--space-1);
    margin-bottom: var(--space-4);
    padding: 3px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.nqt-ex-type-tab {
    flex: 1;
    padding: var(--space-1) var(--space-2);
    border: none;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    font-weight: 500;
    cursor: pointer;
    background: transparent;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.nqt-ex-type-tab.active {
    background: var(--bg-primary);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

/* Balances */
.nqt-ex-balances {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--space-3);
}

.nqt-ex-balance__label {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
}

.nqt-ex-balance__value {
    font-size: var(--font-size-sm);
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--text-primary);
    margin-left: var(--space-2);
}

/* Form Fields */
.nqt-ex-field {
    margin-bottom: var(--space-3);
}

.nqt-ex-field label {
    display: block;
    font-size: var(--font-size-xs);
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-1);
}

.nqt-ex-input-wrap {
    display: flex;
    align-items: center;
    background: var(--bg-tertiary);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast);
}

.nqt-ex-input-wrap:focus-within {
    border-color: var(--accent);
}

.nqt-ex-input-wrap--readonly {
    opacity: 0.7;
}

.nqt-ex-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-size-base);
    font-family: var(--font-mono);
    color: var(--text-primary);
    outline: none;
    min-width: 0;
}

.nqt-ex-input::placeholder {
    color: var(--text-tertiary);
}

.nqt-ex-input-suffix {
    padding-right: var(--space-3);
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    font-weight: 500;
    white-space: nowrap;
}

/* Quick fill */
.nqt-ex-quick-fill {
    display: flex;
    gap: var(--space-1);
    margin-top: var(--space-1);
}

.nqt-ex-quick-fill button {
    flex: 1;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.nqt-ex-quick-fill button:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* Floor buy info */
.nqt-ex-floor-info {
    background: var(--accent-bg);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    margin-bottom: var(--space-3);
}

.nqt-ex-floor-rate {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-1);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.nqt-ex-floor-rate strong {
    font-family: var(--font-mono);
    color: var(--accent-text);
}

.nqt-ex-floor-desc {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    margin: 0;
    line-height: 1.4;
}

.nqt-ex-floor-preview {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    margin-bottom: var(--space-3);
}

.nqt-ex-floor-preview__row {
    display: flex;
    justify-content: space-between;
    font-size: var(--font-size-sm);
    padding: var(--space-1) 0;
}

.nqt-ex-floor-preview__row strong {
    font-family: var(--font-mono);
    color: var(--ex-green-text);
}

.nqt-ex-floor-preview__fee {
    color: var(--text-tertiary);
    font-size: var(--font-size-xs);
}

/* Fee info */
.nqt-ex-fee-info {
    display: flex;
    justify-content: space-between;
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    padding: var(--space-2) 0;
    border-top: 1px solid var(--border-light);
    margin-bottom: var(--space-3);
}

/* Market estimate */
.nqt-ex-market-info {
    text-align: center;
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    padding: var(--space-3);
}

/* Submit button */
.nqt-ex-submit {
    display: block;
    width: 100%;
    padding: var(--space-3);
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: center;
    text-decoration: none;
}

.nqt-ex-submit--buy {
    background: var(--ex-green);
    color: white;
}

.nqt-ex-submit--buy:hover { opacity: 0.9; transform: translateY(-1px); }

.nqt-ex-submit--sell {
    background: var(--ex-red);
    color: white;
}

.nqt-ex-submit--sell:hover { opacity: 0.9; transform: translateY(-1px); }

.nqt-ex-submit--login {
    background: var(--accent);
    color: white;
}

.nqt-ex-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ═══ Recent Trades ═══ */
.nqt-ex-trades {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    overflow: hidden;
}

.nqt-ex-trades-header {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--space-2);
    padding: 0 var(--space-2) var(--space-2);
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-light);
}

.nqt-ex-trades-list {
    max-height: 440px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.nqt-ex-trade-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--space-2);
    padding: 3px var(--space-2);
    font-size: var(--font-size-xs);
    font-family: var(--font-mono);
    transition: background var(--transition-fast);
    animation: tradeFlash 0.6s ease;
}

@keyframes tradeFlash {
    0% { background: var(--accent-bg); }
    100% { background: transparent; }
}

.nqt-ex-trade-row--buy .nqt-ex-trade-price { color: var(--ex-green-text); }
.nqt-ex-trade-row--sell .nqt-ex-trade-price { color: var(--ex-red-text); }

.nqt-ex-trade-time {
    color: var(--text-tertiary);
    text-align: right;
}

/* ═══ My Orders ═══ */
.nqt-ex-my-orders {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
}

.nqt-ex-my-orders-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-3);
}

.nqt-ex-my-orders-tabs {
    display: flex;
    gap: var(--space-1);
}

.nqt-ex-my-tab {
    padding: var(--space-1) var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: transparent;
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.nqt-ex-my-tab.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.nqt-ex-my-orders-table {
    overflow-x: auto;
}

.nqt-ex-my-orders-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-xs);
}

.nqt-ex-my-orders-table th {
    text-align: left;
    padding: var(--space-2);
    color: var(--text-tertiary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
}

.nqt-ex-my-orders-table td {
    padding: var(--space-2);
    color: var(--text-primary);
    font-family: var(--font-mono);
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
}

.nqt-ex-cancel-btn {
    padding: 3px 10px;
    border: 1px solid var(--ex-red);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--ex-red-text);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.nqt-ex-cancel-btn:hover {
    background: var(--ex-red-bg);
}

.nqt-ex-badge-buy { color: var(--ex-green-text); font-weight: 600; }
.nqt-ex-badge-sell { color: var(--ex-red-text); font-weight: 600; }

.nqt-ex-empty {
    text-align: center;
    padding: var(--space-6) !important;
    color: var(--text-tertiary);
    font-family: var(--font-sans) !important;
}

/* ═══ Mobile Responsive ═══ */
@media (max-width: 767px) {
    .nqt-ex-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .nqt-ex-stats {
        width: 100%;
        justify-content: space-between;
    }
    .nqt-ex-my-orders-header {
        flex-direction: column;
        gap: var(--space-2);
        align-items: flex-start;
    }
}
