/* ========== Chart Modal Styles ========== */
.chart-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(
            120% 120% at 50% 0%,
            rgba(22, 209, 149, 0.08),
            transparent 55%
        ),
        rgba(6, 7, 14, 0.68);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    backdrop-filter: blur(10px) saturate(120%);
    -webkit-backdrop-filter: blur(10px) saturate(120%);
    animation: modalFade 0.25s ease-out;
}

@keyframes modalFade {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.chart-modal.hidden {
    display: none;
    visibility: hidden;
    opacity: 0;
}

.chart-modal-content {
    position: relative;
    background:
        linear-gradient(
            180deg,
            rgba(24, 27, 47, 0.98),
            rgba(15, 17, 32, 0.98)
        );
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 20px;
    box-shadow:
        0 30px 80px rgba(0, 0, 0, 0.65),
        0 0 0 1px rgba(255, 255, 255, 0.02) inset,
        0 1px 0 rgba(255, 255, 255, 0.06) inset;
    max-width: 900px;
    width: 100%;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideIn 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Soft accent glow along the very top edge of the card. */
.chart-modal-content::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(
        90deg,
        transparent,
        var(--accent),
        rgba(99, 102, 241, 0.9),
        transparent
    );
    opacity: 0.85;
    z-index: 2;
}

@keyframes slideIn {
    from {
        transform: translateY(16px) scale(0.985);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.chart-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.025),
        transparent
    );
}

.chart-modal-heading {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.chart-modal-badge {
    flex: none;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    font-size: 1.2rem;
    color: var(--accent);
    background: linear-gradient(
        135deg,
        rgba(22, 209, 149, 0.18),
        rgba(99, 102, 241, 0.14)
    );
    border: 1px solid rgba(22, 209, 149, 0.28);
    box-shadow: 0 4px 14px rgba(22, 209, 149, 0.15);
}

.chart-modal-title {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chart-modal-subtitle {
    margin: 2px 0 0;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--muted);
}

.chart-modal-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* "Intraday OI Flow" deep-link from the strike popup into the Flow page. */
.flow-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    text-decoration: none;
    color: #d7f7ec;
    background: linear-gradient(
        135deg,
        rgba(4, 170, 109, 0.22),
        rgba(4, 170, 109, 0.1)
    );
    border: 1px solid rgba(4, 170, 109, 0.55);
    box-shadow: 0 2px 10px rgba(4, 170, 109, 0.12);
    transition:
        transform 0.15s ease,
        box-shadow 0.15s ease,
        background 0.15s ease,
        border-color 0.15s ease;
    white-space: nowrap;
}

.flow-link-btn:hover,
.flow-link-btn:focus {
    color: #eafff8;
    text-decoration: none;
    background: linear-gradient(
        135deg,
        rgba(4, 170, 109, 0.34),
        rgba(4, 170, 109, 0.18)
    );
    border-color: rgba(4, 170, 109, 0.85);
    box-shadow: 0 6px 18px rgba(4, 170, 109, 0.28);
    transform: translateY(-1px);
}

.flow-link-btn:active {
    transform: translateY(0);
}

.flow-link-ico {
    font-size: 1rem;
    line-height: 1;
}

.flow-link-arrow {
    font-weight: 800;
    transition: transform 0.15s ease;
}

.flow-link-btn:hover .flow-link-arrow {
    transform: translateX(3px);
}

.chart-modal-close {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    font-size: 1.5rem;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
    padding: 0;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    transition:
        background 0.15s,
        color 0.15s,
        border-color 0.15s,
        transform 0.15s;
}

.chart-modal-close:hover {
    background: rgba(255, 93, 108, 0.14);
    border-color: rgba(255, 93, 108, 0.4);
    color: #ffb3ba;
    transform: rotate(90deg);
}

.chart-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.chart-container {
    position: relative;
    width: 100%;
    height: 400px;
    margin-bottom: 22px;
    padding: 14px 12px 4px;
    background: rgba(10, 11, 20, 0.5);
    border: 1px solid var(--border);
    border-radius: 14px;
}

.chart-container canvas {
    max-height: 100%;
}

.chart-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.chart-recommendation {
    position: relative;
    padding: 16px 18px;
    background:
        radial-gradient(
            80% 140% at 0% 0%,
            rgba(99, 102, 241, 0.14),
            transparent 60%
        ),
        linear-gradient(
            135deg,
            rgba(22, 209, 149, 0.12),
            rgba(22, 209, 149, 0.04)
        );
    border: 1px solid rgba(22, 209, 149, 0.22);
    border-left: 4px solid var(--accent);
    border-radius: 12px;
    margin-bottom: 18px;
    font-size: 0.95rem;
    line-height: 1.65;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}

.advanced-stats {
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.stat-groups-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.stat-group {
    position: relative;
    padding: 14px 16px 12px;
    background: rgba(10, 11, 20, 0.55);
    border: 1px solid var(--border);
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: hidden;
    transition:
        border-color 0.18s ease,
        transform 0.18s ease,
        box-shadow 0.18s ease;
}

.stat-group::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.stat-group--call {
    background: linear-gradient(
        180deg,
        rgba(52, 211, 153, 0.07),
        rgba(10, 11, 20, 0.55)
    );
    border-color: rgba(52, 211, 153, 0.22);
}

.stat-group--call::before {
    background: linear-gradient(90deg, #34d399, rgba(52, 211, 153, 0.2));
}

.stat-group--put {
    background: linear-gradient(
        180deg,
        rgba(248, 113, 113, 0.07),
        rgba(10, 11, 20, 0.55)
    );
    border-color: rgba(248, 113, 113, 0.22);
}

.stat-group--put::before {
    background: linear-gradient(90deg, #f87171, rgba(248, 113, 113, 0.2));
}

.stat-group:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.28);
}

.stat-group--call:hover {
    border-color: rgba(52, 211, 153, 0.45);
}

.stat-group--put:hover {
    border-color: rgba(248, 113, 113, 0.45);
}

.stat-group-title {
    display: block;
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}

.stat-group--call .stat-group-title {
    color: #4ade80;
}

.stat-group--put .stat-group-title {
    color: #fb7185;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-row .stat-label {
    margin-bottom: 0;
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.85rem;
}

.stat-row .stat-value {
    font-size: 0.95rem;
    color: var(--ink);
}

.stat-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 16px 12px;
    background: rgba(10, 11, 20, 0.55);
    border: 1px solid var(--border);
    border-radius: 14px;
    transition:
        border-color 0.18s ease,
        transform 0.18s ease,
        box-shadow 0.18s ease;
}

.stat-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.28);
}

.stat-item--call {
    border-color: rgba(52, 211, 153, 0.28);
    background: linear-gradient(
        180deg,
        rgba(52, 211, 153, 0.08),
        rgba(10, 11, 20, 0.55)
    );
}

.stat-item--put {
    border-color: rgba(248, 113, 113, 0.28);
    background: linear-gradient(
        180deg,
        rgba(248, 113, 113, 0.08),
        rgba(10, 11, 20, 0.55)
    );
}

.stat-item--pcr {
    border-color: rgba(99, 102, 241, 0.28);
    background: linear-gradient(
        180deg,
        rgba(99, 102, 241, 0.08),
        rgba(10, 11, 20, 0.55)
    );
}

.stat-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 4px;
    letter-spacing: 0.06em;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

.stat-item--call .stat-value {
    color: #4ade80;
}

.stat-item--put .stat-value {
    color: #fb7185;
}

.stat-item--pcr .stat-value {
    color: #a5b4fc;
}

/* ========== Strike Price Buttons ========== */
.strike-buttons-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 16px 0;
    padding: 16px;
    background: var(--bg);
    border-radius: 8px;
    border: 1px solid var(--border);
    justify-content: center;
    align-items: center;
}

.strike-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ink);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.strike-btn:hover {
    border-color: var(--accent);
    background: rgba(4, 170, 109, 0.08);
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(4, 170, 109, 0.15);
}

.strike-btn.atm-strike {
    background: linear-gradient(
        135deg,
        rgba(4, 170, 109, 0.15),
        rgba(4, 170, 109, 0.08)
    );
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 700;
}

.strike-btn.atm-strike::before {
    content: "●";
    color: var(--accent);
    font-size: 0.6rem;
}

.strike-btn:active {
    transform: translateY(0);
}

.strike-btn.call-only {
    border-left: 3px solid rgba(52, 211, 153, 0.8);
}

.strike-btn.put-only {
    border-left: 3px solid rgba(248, 113, 113, 0.8);
}

/* Strike price label inside button */
.strike-price {
    font-weight: 700;
    font-size: 1rem;
}

.option-type {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}

/* ========== Strike Buttons Row in Table ========== */
#content .strike-buttons-row {
    margin: 16px 0;
    padding: 12px;
    background: var(--bg);
    border-radius: 8px;
}

#content .strike-buttons-row .strike-btn {
    font-size: 0.85rem;
    padding: 8px 12px;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .chart-modal-content {
        max-width: 95vw;
        max-height: 90vh;
    }

    .chart-modal-body {
        padding: 16px;
    }

    .chart-container {
        height: 300px;
    }

    .chart-stats {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .stat-groups-grid {
        grid-template-columns: 1fr;
    }

    .strike-buttons-container {
        gap: 6px;
        padding: 12px;
    }

    .strike-btn {
        font-size: 0.85rem;
        padding: 8px 10px;
    }
}

@media (max-width: 480px) {
    .chart-modal {
        padding: 10px;
    }

    .chart-modal-header {
        padding: 16px;
    }

    .chart-modal-title {
        font-size: 1.1rem;
    }

    .chart-modal-subtitle {
        display: none;
    }

    .chart-modal-badge {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .chart-modal-close {
        font-size: 1.4rem;
        width: 28px;
        height: 28px;
    }

    /* Keep the deep-link compact on phones — icon + arrow only. */
    .flow-link-txt {
        display: none;
    }

    .flow-link-btn {
        padding: 7px 10px;
    }

    .chart-container {
        height: 250px;
    }

    .strike-buttons-container {
        gap: 4px;
        padding: 8px;
    }

    .strike-btn {
        font-size: 0.75rem;
        padding: 6px 8px;
    }
}

/* ========== Old Responsive Styles ========== */
@media (max-width: 768px) {
    .chart-modal-content {
        max-width: 95vw;
        max-height: 90vh;
    }

    .chart-modal-body {
        padding: 16px;
    }

    .chart-container {
        height: 300px;
    }

    .chart-stats {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .strike-buttons-container {
        gap: 6px;
        padding: 12px;
    }

    .strike-btn {
        font-size: 0.85rem;
        padding: 8px 10px;
    }
}
