/**
 * Trading View Styles
 * Unified with Current Trades dark blue visual system
 */

.tctm-trading-view-wrapper {
    width: 100%;
    max-width: 100%;
    margin: 20px 0;
    background: linear-gradient(180deg, #123C6B 0%, #1E64B7 100%);
    border-radius: 18px;
    padding: 30px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.15);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
    font-weight: 500;
}

/* ==========================================
   Loading State
   ========================================== */
.tctm-chart-loading {
    text-align: center;
    padding: 60px 20px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.tctm-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.15);
    border-top-color: #5EA6FF;
    border-radius: 50%;
    animation: tctm-tv-spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

@keyframes tctm-tv-spin {
    to { transform: rotate(360deg); }
}

.tctm-chart-loading p {
    margin: 0;
    font-size: 16px;
    color: #AFC6E8;
    font-weight: 500;
}

/* ==========================================
   Main Row Layout: 30% Info + 70% Chart
   ========================================== */
.tctm-trade-main-row {
    display: flex;
    gap: 20px;
    width: 100%;
}

/* ==========================================
   Trade Info Section — 30%
   ========================================== */
.tctm-trade-info-section {
    flex: 0 0 30%;
    min-width: 0;
}

.tctm-trade-info-section .item-info {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 20px;
    height: 100%;
}

.tctm-trade-info-section .top {
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 15px;
}

.tctm-trade-info-section .title-h2 {
    font-size: 13px;
    font-weight: 700;
    color: #AFC6E8;
    margin: 0 0 10px 0;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.tctm-trade-info-section .company {
    font-size: 18px;
    font-weight: 700;
    color: #EAF2FF;
    text-decoration: none;
    display: block;
    transition: color 0.2s ease;
}

.tctm-trade-info-section .company:hover {
    color: #5EA6FF;
}

/* Price & trend row */
.tctm-trade-info-section .stock-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 25px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.tctm-trade-info-section .trade-price {
    font-size: 32px;
    font-weight: 700;
    color: #EAF2FF;
    line-height: 1;
}

.tctm-trade-info-section .trend {
    font-size: 15px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.tctm-trade-info-section .trend.trend-up {
    color: #28a745;
    background: rgba(40, 167, 69, 0.15);
    border: 1px solid rgba(40, 167, 69, 0.3);
}

.tctm-trade-info-section .trend.trend-down {
    color: #dc3545;
    background: rgba(220, 53, 69, 0.15);
    border: 1px solid rgba(220, 53, 69, 0.3);
}

.tctm-trade-info-section .trend.trend-icon::before {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    margin-right: 5px;
}

.tctm-trade-info-section .trend.trend-up.trend-icon::before {
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 10px solid #28a745;
}

.tctm-trade-info-section .trend.trend-down.trend-icon::before {
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 10px solid #dc3545;
}

/* Trade detail rows */
.tctm-trade-info-section .details {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tctm-trade-info-section .details-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tctm-trade-info-section .details-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #AFC6E8;
    letter-spacing: 0.08em;
}

.tctm-trade-info-section .details-text {
    font-size: 14px;
    line-height: 1.6;
    color: #EAF2FF;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.07);
    border-left: 3px solid #5EA6FF;
    border-radius: 4px;
}

/* ==========================================
   Chart Container — 70%
   ========================================== */
.tctm-chart-container {
    flex: 0 0 68%;
    min-width: 0;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    overflow: hidden;
}

/* Chart Header with Navigation */
.tctm-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.06);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tctm-chart-heading {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    color: #5EA6FF;
    letter-spacing: 0.5px;
}

/* Trade Navigation */
.tctm-trade-nav {
    display: flex;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 8px;
}

.tctm-trade-nav-item {
    margin: 0;
    padding: 0;
}

.tctm-trade-nav-separator {
    color: rgba(255, 255, 255, 0.3);
    font-size: 14px;
    font-weight: 600;
    padding: 0 4px;
}

/* Scoped to .tctm-trade-nav to avoid overriding the sidebar .tctm-nav-link */
.tctm-trade-nav .tctm-nav-link {
    display: inline-block;
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(234, 242, 255, 0.4);
    text-decoration: none;
    border-radius: 6px;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    cursor: pointer;
}

.tctm-trade-nav .tctm-nav-link a {
    color: inherit;
    text-decoration: none;
}

.tctm-trade-nav .tctm-nav-link.active {
    color: #FFFFFF;
    background: rgba(94, 166, 255, 0.25);
    border-color: rgba(94, 166, 255, 0.6);
}

.tctm-trade-nav .tctm-nav-link.active:hover {
    background: rgba(94, 166, 255, 0.4);
    border-color: #5EA6FF;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(94, 166, 255, 0.3);
}

.tctm-trade-nav .tctm-nav-link.disabled {
    color: rgba(234, 242, 255, 0.25);
    cursor: not-allowed;
    opacity: 0.5;
}

/* TrendSpider attribution footer */
.tctm-chart-copyright {
    padding: 10px 18px;
    text-align: center;
    background: rgba(255, 255, 255, 0.04);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 12px;
    color: #AFC6E8;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
}

.tctm-chart-copyright a {
    color: #5EA6FF;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

.tctm-chart-copyright a:hover {
    color: #7CB8FF;
    text-decoration: underline;
}

.tctm-chart-copyright-sep {
    color: rgba(175, 198, 232, 0.4);
    font-size: 11px;
}

.tctm-chart-powered {
    flex-basis: 100%;
    text-align: center;
    font-size: 11px;
    color: rgba(175, 198, 232, 0.5);
    margin-top: 2px;
}

/* TrendSpider chart embed */
#trendspider_chart {
    width: 100%;
    min-height: 560px;
    position: relative; /* required for gate overlay */
}

#trendspider_chart iframe {
    border: none;
    display: block;
}

/* ==========================================
   Transparent Chart Click Layer
   Blocks iframe same-tab redirect and opens
   the appropriate TrendSpider chart in a new tab.
   No blur, no overlay UI, no gate.
   ========================================== */
.tctm-chart-click-layer {
    position: absolute;
    inset: 0;
    z-index: 10;
    cursor: pointer;
    background: transparent;
    display: block;
    text-decoration: none;
}

/* ==========================================
   Error State
   ========================================== */
.tctm-chart-error {
    text-align: center;
    padding: 60px 20px;
    background: rgba(220, 53, 69, 0.1);
    border: 1px solid rgba(220, 53, 69, 0.3);
    border-radius: 12px;
}

.tctm-error-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.tctm-error-message {
    margin: 0;
    font-size: 16px;
    color: #EAF2FF;
    font-weight: 500;
}

/* ==========================================
   Responsive — 768px
   ========================================== */
@media (max-width: 768px) {
    .tctm-trading-view-wrapper {
        padding: 20px 15px;
    }

    .tctm-trade-main-row {
        flex-direction: column;
        gap: 15px;
    }

    .tctm-trade-info-section,
    .tctm-chart-container {
        flex: 1 1 100%;
    }

    .tctm-trade-info-section .title-h2 {
        font-size: 11px;
    }

    .tctm-trade-info-section .company {
        font-size: 16px;
    }

    .tctm-trade-info-section .trade-price {
        font-size: 28px;
    }

    .tctm-trade-info-section .trend {
        font-size: 14px;
        padding: 5px 10px;
    }

    .tctm-trade-info-section .details-text {
        font-size: 14px;
        padding: 10px;
    }

    .tctm-chart-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
        padding: 15px;
    }

    .tctm-chart-heading {
        font-size: 20px;
    }

    .tctm-trade-nav {
        align-self: stretch;
        justify-content: center;
    }

    .tctm-trade-nav .tctm-nav-link {
        padding: 6px 12px;
        font-size: 11px;
    }

    #trendspider_chart {
        min-height: 400px;
    }

    #trendspider_chart iframe {
        height: 400px;
    }

    .tctm-chart-loading,
    .tctm-chart-error {
        padding: 40px 15px;
    }

    .tctm-spinner {
        width: 32px;
        height: 32px;
    }

    .tctm-error-icon {
        font-size: 36px;
    }
}

/* ==========================================
   Responsive — 480px
   ========================================== */
@media (max-width: 480px) {
    .tctm-trade-info-section .company {
        font-size: 14px;
    }

    .tctm-trade-info-section .trade-price {
        font-size: 24px;
    }

    .tctm-trade-info-section .trend {
        font-size: 13px;
        padding: 4px 8px;
    }

    .tctm-trade-info-section .details-title {
        font-size: 10px;
    }

    .tctm-trade-info-section .details-text {
        font-size: 13px;
        padding: 8px;
    }

    .tctm-chart-header {
        padding: 12px;
    }

    .tctm-chart-heading {
        font-size: 18px;
    }

    .tctm-trade-nav .tctm-nav-link {
        padding: 5px 10px;
        font-size: 10px;
    }

    .tctm-trade-nav-separator {
        font-size: 12px;
    }

    #trendspider_chart {
        min-height: 350px;
    }

    #trendspider_chart iframe {
        height: 350px;
    }

    .tctm-chart-loading p,
    .tctm-error-message {
        font-size: 14px;
    }

}
