/* ═══════════════════════════════════════════════════
   🏦 KFOO Market Terminal — Binance-Inspired UI
   Professional dark trading terminal design
   ═══════════════════════════════════════════════════ */

/* ============ Terminal Container ============ */
.mkt-terminal {
    background: #0b0e14;
    border: 1px solid #1e2329;
    border-radius: 16px;
    overflow: hidden;
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6), 0 0 60px rgba(14, 203, 129, 0.03);
}

/* ============ Header ============ */
.mkt-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: linear-gradient(180deg, #12161c, #0b0e14);
    border-bottom: 1px solid #1e2329;
    gap: 12px;
    flex-wrap: wrap;
}

.mkt-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.mkt-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mkt-logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mkt-logo-icon {
    font-size: 22px;
}

.mkt-logo-text {
    font-size: 16px;
    font-weight: 800;
    color: #eaecef;
    letter-spacing: -0.5px;
}

.mkt-live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #0ecb81;
    box-shadow: 0 0 8px #0ecb81;
    animation: mkt-pulse 1.5s ease-in-out infinite;
}

@keyframes mkt-pulse {

    0%,
    100% {
        opacity: 1;
        box-shadow: 0 0 8px #0ecb81;
    }

    50% {
        opacity: 0.5;
        box-shadow: 0 0 16px #0ecb81;
    }
}

.mkt-live-label {
    font-size: 10px;
    font-weight: 700;
    color: #0ecb81;
    letter-spacing: 1px;
}

/* ============ Tabs ============ */
.mkt-tabs {
    display: flex;
    gap: 4px;
}

.mkt-tab {
    padding: 7px 14px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: #848e9c;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    white-space: nowrap;
}

.mkt-tab:hover {
    color: #eaecef;
    background: rgba(255, 255, 255, 0.04);
}

.mkt-tab.active {
    color: #fcd535;
    background: rgba(252, 213, 53, 0.08);
    border-color: rgba(252, 213, 53, 0.2);
}

/* ============ Search ============ */
.mkt-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.mkt-search-icon {
    position: absolute;
    left: 10px;
    font-size: 13px;
    pointer-events: none;
}

.mkt-search {
    width: 180px;
    padding: 7px 12px 7px 32px;
    border-radius: 8px;
    border: 1px solid #2b3139;
    background: #1e2329;
    color: #eaecef;
    font-size: 12px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.mkt-search:focus {
    border-color: #fcd535;
}

.mkt-search::placeholder {
    color: #5e6673;
}

.mkt-update-time {
    font-size: 11px;
    color: #5e6673;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.mkt-collapse-btn {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    border: 1px solid #2b3139;
    background: #1e2329;
    color: #848e9c;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mkt-collapse-btn:hover {
    background: #2b3139;
    color: #eaecef;
}

/* ============ Table ============ */
.mkt-table-wrap {
    max-height: 520px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #2b3139 transparent;
}

.mkt-table-wrap::-webkit-scrollbar {
    width: 6px;
}

.mkt-table-wrap::-webkit-scrollbar-track {
    background: transparent;
}

.mkt-table-wrap::-webkit-scrollbar-thumb {
    background: #2b3139;
    border-radius: 3px;
}

.mkt-col-headers {
    display: grid;
    grid-template-columns: 40px 140px 110px 100px 100px 100px 90px 70px 65px 120px 50px;
    padding: 10px 16px;
    background: #12161c;
    border-bottom: 1px solid #1e2329;
    position: sticky;
    top: 0;
    z-index: 5;
}

.mkt-col-headers .mkt-col {
    font-size: 11px;
    color: #5e6673;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.mkt-sortable {
    cursor: pointer;
    user-select: none;
}

.mkt-sortable:hover {
    color: #eaecef !important;
}

/* ============ Sort Arrows ============ */
.mkt-sortable {
    flex-direction: column;
    gap: 1px;
    padding-top: 6px;
    padding-bottom: 4px;
}

.mkt-hdr-text {
    font-size: 11px;
    line-height: 1;
}

.mkt-sort-arrows {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
    gap: 0;
    margin-top: 1px;
}

.mkt-arrow-up,
.mkt-arrow-down {
    font-size: 7px;
    line-height: 8px;
    color: #2b3139;
    transition: color 0.2s ease;
    cursor: pointer;
}

.mkt-sortable:hover .mkt-arrow-up,
.mkt-sortable:hover .mkt-arrow-down {
    color: #5e6673;
}

.mkt-arrow-active {
    color: #fcd535 !important;
}

.mkt-sort-active .mkt-hdr-text {
    color: #fcd535;
}

/* ============ Rows ============ */
.mkt-rows {
    min-height: 100px;
}

.mkt-row {
    display: grid;
    grid-template-columns: 40px 140px 110px 100px 100px 100px 90px 70px 65px 120px 50px;
    padding: 10px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    cursor: pointer;
    transition: background 0.15s ease;
    align-items: center;
}

.mkt-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.mkt-row:active {
    background: rgba(252, 213, 53, 0.04);
}

.mkt-col {
    font-size: 12px;
    color: #eaecef;
    display: flex;
    align-items: center;
}

.mkt-col-rank {
    color: #5e6673;
    font-weight: 600;
    font-size: 11px;
}

.mkt-col-name {
    gap: 10px;
}

.mkt-coin-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex-shrink: 0;
}

.mkt-coin-info {
    display: flex;
    align-items: baseline;
    gap: 2px;
}

.mkt-coin-base {
    font-weight: 700;
    font-size: 13px;
    color: #eaecef;
}

.mkt-coin-quote {
    font-size: 10px;
    color: #5e6673;
    font-weight: 500;
}

.mkt-col-price {
    font-weight: 700;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.mkt-change-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 5px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.mkt-col-high,
.mkt-col-low {
    font-size: 11px;
    color: #848e9c;
    font-variant-numeric: tabular-nums;
}

.mkt-col-volume {
    font-weight: 600;
    font-size: 12px;
    color: #b7bdc6;
}

.mkt-col-leverage {
    font-size: 12px;
}

.mkt-col-trend {
    justify-content: center;
    overflow: visible;
}

/* ============ Neon Trend Badge ============ */
.mkt-trend-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 6px;
    border-radius: 8px;
    gap: 2px;
    min-width: 85px;
    transition: box-shadow 0.3s ease, border-color 0.3s ease;
    animation: mkt-neon-pulse 2s ease-in-out infinite;
}

@keyframes mkt-neon-pulse {

    0%,
    100% {
        filter: brightness(1);
    }

    50% {
        filter: brightness(1.15);
    }
}

.mkt-trend-label {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    line-height: 1.2;
    text-shadow: 0 0 6px currentColor;
}

.mkt-trend-visual {
    display: flex;
    align-items: flex-end;
    gap: 4px;
}

.mkt-trend-bars {
    display: flex;
    align-items: flex-end;
    gap: 1px;
    margin-left: 2px;
}

.mkt-detail-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid #2b3139;
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.mkt-detail-btn:hover {
    background: rgba(252, 213, 53, 0.1);
    border-color: rgba(252, 213, 53, 0.3);
}

/* ============ Loading & Empty States ============ */
.mkt-loading,
.mkt-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #5e6673;
    font-size: 14px;
    gap: 10px;
}

.mkt-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #2b3139;
    border-top-color: #fcd535;
    border-radius: 50%;
    animation: mkt-spin 0.8s linear infinite;
}

@keyframes mkt-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============ Price Flash Animations ============ */
.mkt-flash-green {
    animation: mkt-row-flash-green 0.6s ease-out;
}

.mkt-flash-red {
    animation: mkt-row-flash-red 0.6s ease-out;
}

@keyframes mkt-row-flash-green {
    0% {
        background: rgba(14, 203, 129, 0.15);
    }

    100% {
        background: transparent;
    }
}

@keyframes mkt-row-flash-red {
    0% {
        background: rgba(246, 70, 93, 0.15);
    }

    100% {
        background: transparent;
    }
}

.mkt-price-flash {
    animation: mkt-value-flash 0.5s ease-out;
}

@keyframes mkt-value-flash {
    0% {
        transform: scale(1.08);
    }

    50% {
        transform: scale(1.04);
    }

    100% {
        transform: scale(1);
    }
}

/* Coin Count Badge */
.mkt-coin-count {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(252, 213, 53, 0.1);
    color: #fcd535;
    border: 1px solid rgba(252, 213, 53, 0.2);
    font-variant-numeric: tabular-nums;
}

/* ============ Detail Modal ============ */
.mkt-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.mkt-modal {
    width: 100%;
    max-width: 1100px;
    max-height: 90vh;
    background: #12161c;
    border: 1px solid #2b3139;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
}

.mkt-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid #1e2329;
    background: #0b0e14;
}

.mkt-modal-title {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.mkt-modal-close {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid #2b3139;
    background: transparent;
    color: #848e9c;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mkt-modal-close:hover {
    background: #f6465d;
    color: white;
    border-color: #f6465d;
}

.mkt-modal-body {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(90vh - 80px);
    scrollbar-width: thin;
    scrollbar-color: #2b3139 transparent;
}

/* Detail Grid */
.mkt-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.mkt-stat-card {
    background: #1e2329;
    border: 1px solid #2b3139;
    border-radius: 10px;
    padding: 12px 14px;
}

.mkt-stat-label {
    font-size: 11px;
    color: #5e6673;
    font-weight: 500;
    margin-bottom: 4px;
}

.mkt-stat-value {
    font-size: 14px;
    font-weight: 700;
    color: #eaecef;
    font-variant-numeric: tabular-nums;
}

/* Chart Section */
.mkt-chart-section {
    margin-bottom: 20px;
}

.mkt-chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 8px;
}

.mkt-chart-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.mkt-chart-title {
    font-size: 13px;
    font-weight: 700;
    color: #eaecef;
}

/* ============ Chart Symbol Search ============ */
.mkt-chart-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.mkt-chart-search-icon {
    position: absolute;
    left: 8px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1;
}

.mkt-chart-search {
    background: #1e2329;
    border: 1px solid #2b3139;
    border-radius: 8px;
    color: #eaecef;
    font-size: 12px;
    padding: 6px 10px 6px 28px;
    width: 200px;
    outline: none;
    font-family: inherit;
    transition: all 0.2s ease;
}

.mkt-chart-search:focus {
    border-color: #fcd535;
    box-shadow: 0 0 8px rgba(252, 213, 53, 0.15);
    width: 240px;
}

.mkt-chart-search::placeholder {
    color: #5e6673;
    font-size: 11px;
}

/* Suggestions Dropdown */
.mkt-chart-suggestions {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    min-width: 300px;
    max-height: 360px;
    overflow-y: auto;
    background: #12161c;
    border: 1px solid #2b3139;
    border-radius: 10px;
    margin-top: 4px;
    z-index: 1000;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    scrollbar-width: thin;
    scrollbar-color: #2b3139 transparent;
}

.mkt-sug-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.15s ease;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.mkt-sug-item:last-child {
    border-bottom: none;
}

.mkt-sug-item:hover,
.mkt-sug-active {
    background: rgba(252, 213, 53, 0.06) !important;
}

.mkt-sug-icon-img {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    flex-shrink: 0;
}

.mkt-sug-name {
    font-size: 12px;
    font-weight: 700;
    color: #eaecef;
    flex: 1;
}

.mkt-sug-price {
    font-size: 11px;
    color: #848e9c;
    font-variant-numeric: tabular-nums;
}

.mkt-sug-change {
    font-size: 10px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    min-width: 60px;
    text-align: right;
}

.mkt-sug-hint {
    font-size: 10px;
    color: #5e6673;
    margin-left: auto;
}

.mkt-sug-custom {
    background: rgba(252, 213, 53, 0.03);
}

.mkt-sug-icon {
    font-size: 14px;
    flex-shrink: 0;
}

.mkt-sug-divider {
    text-align: center;
    padding: 6px 0;
    font-size: 10px;
    color: #5e6673;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

/* Market Toggle (Spot / Futures) */
.mkt-market-toggle {
    display: flex;
    gap: 2px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    padding: 2px;
}

.mkt-market-btn {
    padding: 5px 14px;
    font-size: 11px;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    background: transparent;
    color: #848e9c;
    transition: all 0.2s ease;
    font-family: inherit;
}

.mkt-market-btn:hover {
    color: #eaecef;
    background: rgba(255, 255, 255, 0.06);
}

.mkt-market-btn.active {
    background: rgba(252, 213, 53, 0.12);
    color: #fcd535;
    box-shadow: 0 0 8px rgba(252, 213, 53, 0.1);
}

.mkt-chart-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.mkt-chart-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

/* TradingView Container */
.mkt-tv-container {
    width: 100%;
    height: 550px;
    border-radius: 10px;
    border: 1px solid #1e2329;
    overflow: hidden;
    background: #0b0e14;
}

.mkt-tv-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #5e6673;
    font-size: 14px;
    gap: 10px;
}

/* Timeframe Buttons */
.mkt-tf-buttons {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
}

.mkt-tf-btn {
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid #2b3139;
    background: #1e2329;
    color: #848e9c;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    white-space: nowrap;
}

.mkt-tf-btn:hover {
    color: #eaecef;
    background: #2b3139;
    border-color: #3b4149;
}

.mkt-tf-btn.active {
    color: #fcd535;
    background: rgba(252, 213, 53, 0.1);
    border-color: rgba(252, 213, 53, 0.3);
    box-shadow: 0 0 6px rgba(252, 213, 53, 0.15);
}

/* Order Book */
.mkt-book-section {
    margin-bottom: 20px;
}

.mkt-book-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.mkt-book-side {
    background: #1e2329;
    border-radius: 10px;
    padding: 10px;
    border: 1px solid #2b3139;
}

.mkt-book-header {
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 8px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mkt-book-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 4px;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

/* Recent Trades */
.mkt-trades-section {
    margin-bottom: 10px;
}

.mkt-trades-list {
    background: #1e2329;
    border-radius: 10px;
    padding: 10px;
    border: 1px solid #2b3139;
    max-height: 280px;
    overflow-y: auto;
}

.mkt-trade-row {
    display: grid;
    grid-template-columns: 40px 1fr 80px 70px;
    padding: 4px 6px;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    gap: 8px;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.mkt-trade-row:last-child {
    border-bottom: none;
}

/* ============ Responsive ============ */
@media (max-width: 1024px) {

    .mkt-col-headers,
    .mkt-row {
        grid-template-columns: 30px 120px 90px 85px 1fr 90px 50px;
    }

    .mkt-col-high,
    .mkt-col-low,
    .mkt-col-type,
    .mkt-col-action {
        display: none;
    }
}

@media (max-width: 640px) {
    .mkt-header {
        padding: 10px 14px;
    }

    .mkt-tabs {
        order: 3;
        width: 100%;
        overflow-x: auto;
    }

    .mkt-search {
        width: 120px;
    }

    .mkt-col-headers,
    .mkt-row {
        grid-template-columns: 25px 110px 80px 75px 1fr;
    }

    .mkt-col-high,
    .mkt-col-low,
    .mkt-col-type,
    .mkt-col-action,
    .mkt-col-leverage,
    .mkt-col-trend {
        display: none;
    }

    .mkt-detail-grid {
        grid-template-columns: 1fr 1fr;
    }

    .mkt-book-grid {
        grid-template-columns: 1fr;
    }
}