/* ==========================================================================
   Stock Widget — V6 Glass Terminal Design
   CSS selectors matched to stock-widget.js class names.
   Fonts (Sora, IBM Plex Mono, Outfit) loaded via PHP enqueue, not here.
   ========================================================================== */


/* ==========================================================================
   1. MAIN CONTAINER
   .stock-widget — the card itself, sits inside a content container
   ========================================================================== */

.stock-widget {
    background: linear-gradient(135deg, #0b0e13 0%, #111620 30%, #161d2b 60%, #131722 100%);
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    padding: 28px;
    color: #e4e8f0;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15), 0 1px 4px rgba(0, 0, 0, 0.1);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Ambient effect matching hero ::before */
.stock-widget::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(90,149,206,0.04) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 50%, rgba(149,206,90,0.03) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

/* Reset box-sizing inside widget */
.stock-widget *,
.stock-widget *::before,
.stock-widget *::after {
    box-sizing: border-box;
}


/* ==========================================================================
   2. GLASS PANELS
   Frosted glass effect used by inner cards
   ========================================================================== */

.stock-widget .glass {
    background: #1e2435;
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 12px;
    position: relative;
    z-index: 1;
    box-shadow: 0 0 24px rgba(149, 206, 90, 0.04), 0 2px 8px rgba(0, 0, 0, 0.15);
}

.stock-widget .glass-bright {
    background: #1e2435;
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 12px;
    position: relative;
    z-index: 1;
    box-shadow: 0 0 24px rgba(149, 206, 90, 0.04), 0 2px 8px rgba(0, 0, 0, 0.15);
}


/* ==========================================================================
   3. HEADER — logo + company name + LIVE badge + refresh
   JS class: .v6-top
   ========================================================================== */

.stock-widget .v6-top {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
    position: relative;
    z-index: 1;
}

.stock-widget .v6-top > div:nth-child(2) {
    flex: 1;
    min-width: 0;
}

.stock-widget .v6-top h2 {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    margin: 0;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stock-widget .v6-top .sub {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.45);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stock-widget .v6-badge {
    font-size: 10px;
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(149, 206, 90, 0.15);
    color: #95ce5a;
    font-weight: 600;
    flex-shrink: 0;
    display: inline-block;
    white-space: nowrap;
    line-height: 1.4;
}

/* Refresh button */
.stock-widget .stock-widget-refresh {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.4);
    padding: 6px 8px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.stock-widget .stock-widget-refresh:hover {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.7);
}

.stock-widget .stock-widget-refresh.refreshing svg {
    animation: spin 0.8s linear infinite;
}

/* Logo as <img> */
.stock-widget .stock-widget-logo {
    width: 46px;
    height: 46px;
    flex-shrink: 0;
}

.stock-widget .stock-widget-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 10px;
}

/* Logo placeholder — colored square with letter */
.stock-widget .stock-widget-logo-placeholder {
    width: 46px;
    height: 46px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 20px;
    color: #fff;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.stock-widget .stock-widget-logo-placeholder::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent 50%);
}


/* ==========================================================================
   4. MAIN GRID — price card (left) + metrics/reco (right)
   JS class: .v6-grid
   ========================================================================== */

.stock-widget .v6-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 16px;
    position: relative;
    z-index: 1;
}


/* ==========================================================================
   5. PRICE CARD — large price, change chips, OHLC, CTA button
   JS classes: .v6-price-card, .v6-price, .v6-changes, .v6-chip, .v6-ohlc
   ========================================================================== */

.stock-widget .v6-price-card {
    padding: 24px;
    overflow: hidden;
}

/* Main price — large mono with glow */
.stock-widget .v6-price {
    font-size: 44px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -1.5px;
    text-shadow: 0 0 30px rgba(149, 206, 90, 0.25), 0 0 80px rgba(149, 206, 90, 0.08);
    line-height: 1.2;
}

/* Price row — price left, sparkline right */
.stock-widget .v6-price-row {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}
.stock-widget .v6-price-left {
    flex-shrink: 0;
}
.stock-widget .v6-sparkline {
    flex: 1;
    min-width: 100px;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-end;
    padding-right: 4px;
}
.stock-widget .v6-sparkline-svg {
    width: 100%;
    max-width: 260px;
    height: 70px;
}
.stock-widget .v6-sparkline-tabs {
    display: flex;
    gap: 4px;
    margin-top: 6px;
}
.stock-widget .v6-sparkline-tab {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.4);
    font-size: 11px;
    padding: 2px 8px;
    cursor: pointer;
    transition: all 0.2s;
}
.stock-widget .v6-sparkline-tab:hover {
    color: rgba(255, 255, 255, 0.7);
    border-color: rgba(255, 255, 255, 0.15);
}
.stock-widget .v6-sparkline-tab.active {
    color: #95ce5a;
    border-color: rgba(149, 206, 90, 0.3);
    background: rgba(149, 206, 90, 0.08);
}

/* Market status — next to LIVE badge */
.stock-widget .v6-market-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
}
.stock-widget .v6-market-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.stock-widget .v6-market-label {
    font-weight: 600;
    color: rgba(255, 255, 255, 0.75);
}
.stock-widget .v6-market-time {
    color: rgba(255, 255, 255, 0.45);
    font-size: 12px;
}

/* Change chips row */
.stock-widget .v6-changes {
    display: flex;
    gap: 8px;
    margin: 10px 0 18px;
    flex-wrap: wrap;
}

/* Individual chip (positive by default) */
.stock-widget .v6-chip {
    font-size: 13px;
    font-weight: 600;
    padding: 5px 14px;
    border-radius: 20px;
    background: rgba(48, 209, 88, 0.12);
    color: #5fe87a;
    border: 1px solid rgba(48, 209, 88, 0.15);
}

/* Negative variant — JS uses .v6-chip-negative */
.stock-widget .v6-chip.v6-chip-negative {
    background: rgba(255, 69, 58, 0.12);
    color: #ff453a;
    border-color: rgba(255, 69, 58, 0.15);
}

/* OHLC grid — 2-column */
.stock-widget .v6-ohlc {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 18px;
}

.stock-widget .v6-ohlc-item {
    display: flex;
    justify-content: space-between;
    padding: 9px 14px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    font-size: 13px;
}

.stock-widget .v6-ohlc-item .lbl {
    color: rgba(255, 255, 255, 0.4);
}

.stock-widget .v6-ohlc-item .val {
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
}

/* CTA button — gradient green with glow */
.stock-widget .v6-cta {
    display: block;
    text-align: center;
    padding: 14px;
    border-radius: 10px;
    background: linear-gradient(135deg, #95ce5a, #7db84a);
    color: #0a1420;
    font-weight: 700;
    font-size: 15px;
    text-decoration: none;
    box-shadow: 0 0 20px rgba(149, 206, 90, 0.3), 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.25s ease;
    letter-spacing: 0.3px;
    cursor: pointer;
    border: none;
}

/* Tooltip on metrics */
.stock-widget .v6-tip {
    display: inline-block;
    cursor: help;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.25);
    position: relative;
    vertical-align: middle;
    margin-left: 3px;
    transition: color 0.2s;
}
.stock-widget .v6-tip:hover {
    color: rgba(255, 255, 255, 0.6);
}
.stock-widget .v6-tip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #1a2030;
    color: rgba(255, 255, 255, 0.85);
    font-size: 12px;
    font-weight: 400;
    line-height: 1.5;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    width: 240px;
    white-space: normal;
    text-transform: none;
    letter-spacing: 0;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 100;
}
.stock-widget .v6-tip:hover::after {
    opacity: 1;
    visibility: visible;
}
/* Arrow */
.stock-widget .v6-tip::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1a2030;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 101;
}
.stock-widget .v6-tip:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Company activities description */
.stock-widget .v6-activities {
    margin-top: 14px;
    font-size: 13px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.5);
}
.stock-widget .v6-activities-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.35);
    margin-bottom: 4px;
}

.stock-widget .v6-cta:hover {
    box-shadow: 0 0 30px rgba(149, 206, 90, 0.45), 0 6px 20px rgba(0, 0, 0, 0.3);
    transform: translateY(-1px);
    color: #0a1420;
    text-decoration: none;
}


/* ==========================================================================
   6. RIGHT COLUMN — metrics + recommendations
   JS class: .v6-right
   ========================================================================== */

.stock-widget .v6-right {
    display: flex;
    flex-direction: column;
    gap: 12px;
}


/* ==========================================================================
   7. METRICS CARD — EPS, P/E, Market Cap, Dividends
   JS classes: .v6-met-card, .v6-met-grid, .v6-met
   ========================================================================== */

.stock-widget .v6-met-card {
    padding: 16px;
}

/* 52-Week Range Bar */
.stock-widget .v6-week-range {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.stock-widget .v6-week-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.45);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}
.stock-widget .v6-week-bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.stock-widget .v6-week-val {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    white-space: nowrap;
}
.stock-widget .v6-week-bar {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    position: relative;
}
.stock-widget .v6-week-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff453a, #ffd43a, #30d158);
    border-radius: 3px;
    opacity: 0.6;
}
.stock-widget .v6-week-dot {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    background: #fff;
    border-radius: 50%;
    border: 2px solid #95ce5a;
    box-shadow: 0 0 6px rgba(149, 206, 90, 0.4);
}

.stock-widget .v6-met-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.stock-widget .v6-met {
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
}

.stock-widget .v6-met label {
    display: block;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.45);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stock-widget .v6-met .val {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
}


/* ==========================================================================
   8. RECOMMENDATIONS BAR
   JS classes: .v6-reco-card, .v6-reco-title, .v6-reco-bar, .v6-reco-seg-*,
               .v6-reco-labels
   ========================================================================== */

.stock-widget .v6-reco-card {
    padding: 16px;
}

.stock-widget .v6-reco-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 10px;
}

/* Segmented progress bar */
.stock-widget .v6-reco-bar {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.04);
}

.stock-widget .v6-reco-bar div {
    height: 100%;
    transition: width 0.8s ease;
}

.stock-widget .v6-reco-seg-sb {
    background: #30d158;
    box-shadow: 0 0 10px rgba(48, 209, 88, 0.4);
}

.stock-widget .v6-reco-seg-b {
    background: #95ce5a;
    box-shadow: 0 0 8px rgba(149, 206, 90, 0.3);
}

.stock-widget .v6-reco-seg-h {
    background: #ffd43a;
}

.stock-widget .v6-reco-seg-s {
    background: #ff9f43;
}

.stock-widget .v6-reco-seg-ss {
    background: #ff453a;
    box-shadow: 0 0 8px rgba(255, 69, 58, 0.3);
}

/* Labels under the bar */
.stock-widget .v6-reco-labels {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.45);
    gap: 4px;
}

.stock-widget .v6-reco-labels > span {
    flex: 1;
    text-align: center;
    min-width: 0;
}

.stock-widget .v6-reco-labels strong {
    color: rgba(255, 255, 255, 0.85);
    font-size: 14px;
    display: block;
}


/* ==========================================================================
   9. EXPANDABLE COMPANY INFO
   JS classes: .v6-info, .v6-info-toggle, .v6-info-body, .v6-info-grid,
               .v6-info-item, .v6-full
   ========================================================================== */

.stock-widget .v6-info {
    margin-top: 18px;
    position: relative;
    z-index: 1;
}

.stock-widget .v6-info-toggle {
    width: 100%;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.45);
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.stock-widget .v6-info-toggle:hover {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.65);
}

.stock-widget .v6-info-toggle .arr {
    font-size: 10px;
}

.stock-widget .v6-info-body {
    display: none;
    margin-top: 12px;
}

.stock-widget .v6-info-body.open {
    display: block;
    animation: fadeIn 0.3s ease;
    padding-bottom: 4px;
}

.stock-widget .v6-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
    max-width: 100%;
    overflow: hidden;
}

.stock-widget .v6-info-item {
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
}

.stock-widget .v6-info-item label {
    display: block;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.45);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 3px;
}

.stock-widget .v6-info-item span {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 500;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Full-width info item (spans all columns) */
.stock-widget .v6-full {
    grid-column: 1 / -1;
}


/* ==========================================================================
   10. LOADING STATE
   ========================================================================== */

.stock-widget-loading {
    padding: 60px 28px;
    text-align: center;
    background: linear-gradient(135deg, #0c1220 0%, #132038 50%, #0e1a2e 100%);
    border-radius: 16px;
    color: rgba(255, 255, 255, 0.4);
    font-size: 14px;
}

.stock-widget-loading::after {
    content: '';
    display: block;
    width: 32px;
    height: 32px;
    margin: 16px auto 0;
    border: 2px solid rgba(149, 206, 90, 0.15);
    border-top-color: #95ce5a;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}


/* ==========================================================================
   11. ERROR STATE
   ========================================================================== */

.stock-widget-error {
    padding: 40px 28px;
    text-align: center;
    background: linear-gradient(135deg, #0c1220 0%, #132038 50%, #0e1a2e 100%);
    border-radius: 16px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
}

.stock-widget-error .error-icon {
    font-size: 28px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.stock-widget-error .error-message {
    margin-bottom: 16px;
}

.stock-widget-error .retry-btn {
    display: inline-block;
    padding: 8px 20px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.stock-widget-error .retry-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
}


/* ==========================================================================
   12. ANIMATIONS
   ========================================================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}


/* ==========================================================================
   13. CHART INTEGRATION — виджет + TradingView как единый блок
   ========================================================================== */

/* Когда за виджетом идёт график — убираем нижние скругления */
.stock-widget-with-chart .stock-widget {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}
/* График прилипает к виджету, фон совпадает с hero */
.stock-widget-with-chart .tv-chart-wrapper {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    margin-top: -1px;
    background: linear-gradient(135deg, #0b0e13 0%, #111620 30%, #161d2b 60%, #131722 100%);
    border-color: rgba(255, 255, 255, 0.06);
}
.stock-widget-with-chart .tv-chart-wrapper .tv-chart-header {
    background: transparent;
    border-bottom-color: rgba(255, 255, 255, 0.06);
}
.stock-widget-with-chart .tv-chart-wrapper .tv-chart-footer {
    background: transparent;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}


/* ==========================================================================
   14. RESPONSIVE — tablet and below
   ========================================================================== */

@media (max-width: 768px) {
    .stock-widget {
        padding: 20px;
    }

    .stock-widget .v6-grid {
        grid-template-columns: 1fr;
    }

    .stock-widget .v6-price {
        font-size: 32px;
    }

    .stock-widget .v6-top h2 {
        font-size: 16px;
    }

    .stock-widget .v6-met-grid {
        grid-template-columns: 1fr 1fr;
    }

    .stock-widget .v6-info-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .stock-widget {
        padding: 16px;
        border-radius: 12px;
    }

    .stock-widget .v6-top {
        gap: 10px;
        margin-bottom: 18px;
    }

    .stock-widget .v6-top h2 {
        font-size: 15px;
    }

    .stock-widget .stock-widget-logo-placeholder,
    .stock-widget .stock-widget-logo {
        width: 38px;
        height: 38px;
    }

    .stock-widget .stock-widget-logo-placeholder {
        font-size: 16px;
        border-radius: 8px;
    }

    .stock-widget .v6-price {
        font-size: 28px;
        letter-spacing: -1px;
    }

    .stock-widget .v6-chip {
        font-size: 11px;
        padding: 4px 10px;
    }

    .stock-widget .v6-ohlc {
        grid-template-columns: 1fr;
    }

    .stock-widget .v6-met .val {
        font-size: 15px;
    }

    .stock-widget .v6-info-grid {
        grid-template-columns: 1fr;
    }

    .stock-widget .v6-reco-labels {
        font-size: 9px;
    }

    .stock-widget .v6-reco-labels strong {
        font-size: 12px;
    }
}
