/*
 * BokaroTraderFx - Professional Market Insights Stylesheet
 * 
 * Defines premium dark glassmorphism layouts, session clock countdown panels,
 * index asset dashboard cards with simulated micro-sparklines, interactive checkboxes,
 * calendar impact level badges, and responsive grids.
 */

.insights-section {
    padding-top: calc(80px + var(--space-xl));
    padding-bottom: var(--space-xxl);
    background-color: transparent;
    position: relative;
    overflow: hidden;
}

@media (max-width: 900px) {
    .insights-section {
        padding-top: calc(64px + var(--space-lg));
    }
}

.insights-section::before {
    content: '';
    position: absolute;
    top: -150px;
    left: -150px;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.03) 0%, transparent 70%);
    z-index: 0;
    pointer-events: none;
}

.insights-container {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
}

/* 1. Hero Header styling */
.insights-hero {
    text-align: center;
    padding: var(--space-lg) 0 0 0;
}

.insights-tagline {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    color: var(--brand-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-xs);
    display: inline-block;
}

.insights-title {
    font-size: var(--font-size-4xl);
    font-weight: var(--font-weight-bold);
    background: linear-gradient(135deg, var(--text-primary) 30%, #A5B4FC 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
    margin-bottom: var(--space-sm);
}

.insights-subtitle {
    font-size: var(--font-size-base);
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
    line-height: var(--line-height-body);
}

/* Workspace panel base styling */
.insights-panel {
    background: var(--bg-glass);
    border: var(--border-glass);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    box-shadow: var(--shadow-glass);
    position: relative;
    overflow: hidden;
}

.panel-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color-subtle);
    padding-bottom: var(--space-xs);
    margin-bottom: var(--space-md);
}

.insights-panel-title {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0;
}

.insights-panel.accent-indigo {
    border-top: 3px solid var(--brand-primary);
}
.insights-panel.accent-emerald {
    border-top: 3px solid var(--color-success);
}
.insights-panel.accent-blue {
    border-top: 3px solid #3B82F6;
}
.insights-panel.accent-purple {
    border-top: 3px solid #8B5CF6;
}
.insights-panel.accent-amber {
    border-top: 3px solid var(--color-warning);
}

/* 2. Session Clocks Grid */
.sessions-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-md);
}

.session-card {
    background: rgba(255, 255, 255, 0.015);
    border: var(--border-glass);
    border-radius: var(--radius-sm);
    padding: var(--space-md);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: transform var(--transition-normal), border-color var(--transition-normal);
}

.session-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.12);
}

.session-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.session-title {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    color: var(--text-secondary);
}

.session-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 9px;
    font-weight: var(--font-weight-bold);
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 4px;
}

.session-status-badge.active {
    background-color: rgba(16, 185, 129, 0.1);
    color: #10B981;
    border: 1px solid rgba(16, 185, 129, 0.15);
}

.session-status-badge.inactive {
    background-color: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.session-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.session-status-badge.active .session-status-dot {
    background-color: #10B981;
    box-shadow: 0 0 8px #10B981;
    animation: pulseGlow 2s infinite;
}

.session-status-badge.inactive .session-status-dot {
    background-color: var(--text-muted);
}

@keyframes pulseGlow {
    0% { transform: scale(0.9); opacity: 0.6; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.6; }
}

.session-hours {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.session-countdown {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    font-family: var(--font-mono);
    margin-top: 4px;
}

/* 3. Market Dashboard Asset Cards */
.market-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-md);
}

.market-asset-card {
    background: rgba(255, 255, 255, 0.015);
    border: var(--border-glass);
    border-radius: var(--radius-sm);
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
    overflow: hidden;
    transition: transform var(--transition-normal), border-color var(--transition-normal);
}

.market-asset-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.15);
}

.asset-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}

.asset-symbol {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    color: var(--text-muted);
}

.asset-name {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
}

.asset-price {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    font-family: var(--font-mono);
    letter-spacing: -0.01em;
}

.asset-change {
    font-size: 11px;
    font-weight: var(--font-weight-semibold);
    font-family: var(--font-mono);
    display: flex;
    align-items: center;
    gap: 2px;
}

.asset-change.bullish {
    color: #10B981;
}

.asset-change.bearish {
    color: #EF4444;
}

.asset-change.neutral {
    color: #3B82F6;
}

/* Micro-sparkline charts styling */
.asset-sparkline-container {
    height: 35px;
    margin-top: var(--space-sm);
    width: 100%;
}

.sparkline-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.sparkline-path {
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sparkline-path.bullish {
    stroke: #10B981;
}

.sparkline-path.bearish {
    stroke: #EF4444;
}

.sparkline-path.neutral {
    stroke: #3B82F6;
}

/* 4. Economic Calendar styling */
.calendar-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.calendar-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-xs);
    text-align: left;
}

.calendar-table th {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-weight: var(--font-weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.calendar-table td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    vertical-align: middle;
}

.calendar-table tr:last-child td {
    border-bottom: none;
}

.calendar-table tr:hover td {
    background: rgba(255, 255, 255, 0.01);
}

.calendar-time {
    font-family: var(--font-mono);
    color: var(--text-primary);
    font-weight: var(--font-weight-medium);
}

.calendar-country {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.country-flag {
    width: 16px;
    height: 12px;
    border-radius: 2px;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.calendar-currency {
    font-family: var(--font-mono);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
}

.calendar-event {
    color: var(--text-primary);
    font-weight: var(--font-weight-medium);
}

/* Impact Badge Styling */
.impact-badge {
    font-size: 8px;
    font-weight: var(--font-weight-bold);
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 4px;
    letter-spacing: 0.02em;
    display: inline-block;
    border-width: 1px;
    border-style: solid;
}

.impact-badge.high {
    background-color: rgba(239, 68, 68, 0.12);
    color: #F87171;
    border-color: rgba(239, 68, 68, 0.2);
}

.impact-badge.medium {
    background-color: rgba(245, 158, 11, 0.12);
    color: #FBBF24;
    border-color: rgba(245, 158, 11, 0.2);
}

.impact-badge.low {
    background-color: rgba(59, 130, 246, 0.1);
    color: #60A5FA;
    border-color: rgba(59, 130, 246, 0.15);
}

/* 5. 2-Column Watchlist + Checklist & Notes layout */
.insights-double-grid {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: var(--space-md);
    align-items: start;
}

.insights-column {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* Watchlist table customization */
.watchlist-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.watchlist-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-xs);
}

.watchlist-table th {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-weight: var(--font-weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    text-align: left;
}

.watchlist-table td {
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    vertical-align: middle;
}

.watchlist-table tr:hover td {
    background: rgba(255, 255, 255, 0.015);
}

.bias-tag {
    font-size: 8px;
    font-weight: var(--font-weight-bold);
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
    border: 1px solid transparent;
}

.bias-tag.bullish {
    background-color: rgba(16, 185, 129, 0.1);
    color: #10B981;
    border-color: rgba(16, 185, 129, 0.15);
}

.bias-tag.bearish {
    background-color: rgba(239, 68, 68, 0.1);
    color: #EF4444;
    border-color: rgba(239, 68, 68, 0.15);
}

.bias-tag.neutral {
    background-color: rgba(255, 255, 255, 0.02);
    color: var(--text-muted);
    border-color: rgba(255, 255, 255, 0.05);
}

.trend-badge {
    font-size: 9px;
    font-weight: var(--font-weight-semibold);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.trend-badge.up {
    color: #34D399;
}

.trend-badge.down {
    color: #F87171;
}

.trend-badge.flat {
    color: var(--text-muted);
}

/* Shared Item Styling */
.checklist-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.checklist-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.checklist-item:hover {
    background: rgba(255, 255, 255, 0.02);
    border-color: rgba(255, 255, 255, 0.06);
}

.save-status-text {
    font-size: 10px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* 6. Responsive Breakpoints */
@media (max-width: 1300px) {
    .market-dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .sessions-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .market-dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .sessions-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 580px) {
    .market-dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .sessions-grid {
        grid-template-columns: 1fr;
    }
}

/* Market Status Card Improvements */
.market-status-container {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.market-session-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
}

.market-session-badge {
    font-size: 10px;
    font-weight: var(--font-weight-bold);
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 0.03em;
    border: 1px solid transparent;
}

.market-session-badge.sydney {
    background-color: rgba(99, 102, 241, 0.15);
    color: #A5B4FC;
    border-color: rgba(99, 102, 241, 0.25);
}

.market-session-badge.tokyo {
    background-color: rgba(139, 92, 246, 0.15);
    color: #C084FC;
    border-color: rgba(139, 92, 246, 0.25);
}

.market-session-badge.london {
    background-color: rgba(16, 185, 129, 0.15);
    color: #34D399;
    border-color: rgba(16, 185, 129, 0.25);
}

.market-session-badge.ny {
    background-color: rgba(245, 158, 11, 0.15);
    color: #FBBF24;
    border-color: rgba(245, 158, 11, 0.25);
}

.market-session-countdown {
    font-family: var(--font-mono);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
}

.market-session-countdown.opens {
    color: var(--text-muted);
}

.market-session-countdown.closes {
    color: #10B981;
}

/* Market Data Loading & Status States */
.data-loading {
    animation: data-pulse 1.5s infinite alternate;
    opacity: 0.6;
}

@keyframes data-pulse {
    0% { opacity: 0.4; }
    100% { opacity: 0.8; }
}

#market-data-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-mono);
    font-size: var(--font-size-xs);
    transition: color var(--transition-fast) ease;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-muted);
    flex-shrink: 0;
}

.status-dot.live {
    background-color: #10B981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
    animation: dot-pulse 2s infinite;
}

.status-dot.error {
    background-color: var(--color-danger);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
}

@keyframes dot-pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
    70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ==========================================
   Phase 1E TradingView Widget Rules
   ========================================== */

/* ---- Market Snapshot 2x2 Grid ---- */
.insights-market-snapshot-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    width: 100%;
}

.insights-market-snapshot-card {
    min-width: 0;
    height: 126px;
    overflow: hidden;
    border-radius: var(--radius-lg, var(--radius-md));
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.02);
}

/* Pin every container layer so the injected iframe fills the card */
.insights-market-snapshot-card .insights-single-quote,
.insights-market-snapshot-card .tradingview-widget-container__widget {
    width: 100%;
    height: 126px;
}

/* Scoped iframe rule — does NOT affect Calendar or Chart iframes */
.insights-market-snapshot-card iframe {
    display: block;
    width: 100% !important;
    height: 126px !important;
    border: 0;
}

.insights-widget-disclosure {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    text-align: center;
    margin-top: var(--space-xs);
    opacity: 0.8;
}

/* ---- Economic Calendar ---- */
/* All four container layers must carry the same explicit height */
.insights-tradingview-calendar,
.insights-tradingview-calendar > .tradingview-widget-container,
.insights-tradingview-calendar .tradingview-widget-container__widget {
    display: block;
    width: 100%;
    min-width: 0;
    height: 620px;
    min-height: 620px;
    overflow: hidden;
    border-radius: var(--radius-md);
}

.insights-tradingview-calendar iframe {
    display: block;
    width: 100% !important;
    height: 620px !important;
    min-height: 620px !important;
    border: 0;
}

/* ---- Interactive Market Chart ---- */
.insights-tradingview-chart,
.insights-tradingview-chart > .tradingview-widget-container,
.insights-tradingview-chart .tradingview-widget-container__widget {
    display: block;
    width: 100%;
    min-width: 0;
    height: 720px;
    min-height: 720px;
    overflow: hidden;
    border-radius: var(--radius-md);
}

.insights-tradingview-chart iframe {
    display: block;
    width: 100% !important;
    height: 720px !important;
    min-height: 720px !important;
    border: 0;
}

/* ---- Misc ---- */
.insights-chart-subtitle {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-top: 2px;
    line-height: 1.4;
}

.insights-widget-fallback {
    padding: var(--space-md);
    text-align: center;
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    background-color: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-md);
    margin-top: var(--space-sm);
}

.insights-widget-fallback a {
    color: var(--brand-primary);
    text-decoration: underline;
}

/* ---- Tablet ≤ 1024px ---- */
@media (max-width: 1024px) {
    .insights-tradingview-calendar,
    .insights-tradingview-calendar > .tradingview-widget-container,
    .insights-tradingview-calendar .tradingview-widget-container__widget {
        height: 560px;
        min-height: 560px;
    }
    .insights-tradingview-calendar iframe {
        height: 560px !important;
        min-height: 560px !important;
    }

    .insights-tradingview-chart,
    .insights-tradingview-chart > .tradingview-widget-container,
    .insights-tradingview-chart .tradingview-widget-container__widget {
        height: 620px;
        min-height: 620px;
    }
    .insights-tradingview-chart iframe {
        height: 620px !important;
        min-height: 620px !important;
    }
}

/* ---- Market Snapshot: collapse to 1 column at ≤700px ---- */
@media (max-width: 700px) {
    .insights-market-snapshot-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

/* ---- Mobile ≤ 768px ---- */
@media (max-width: 768px) {

    .insights-tradingview-calendar,
    .insights-tradingview-calendar > .tradingview-widget-container,
    .insights-tradingview-calendar .tradingview-widget-container__widget {
        height: 500px;
        min-height: 500px;
    }
    .insights-tradingview-calendar iframe {
        height: 500px !important;
        min-height: 500px !important;
    }

    .insights-tradingview-chart,
    .insights-tradingview-chart > .tradingview-widget-container,
    .insights-tradingview-chart .tradingview-widget-container__widget {
        height: 500px;
        min-height: 500px;
    }
    .insights-tradingview-chart iframe {
        height: 500px !important;
        min-height: 500px !important;
    }
}
