/* Stock Analysis Page Styles - Professional Enterprise + Mobile-App Edition */

/* Page-level layout */
.stock-analysis-page {
    scroll-behavior: smooth;
    background: var(--bg-body);
}

.stock-page-container {
    padding-top: 93px; /* navbar (57px) + ticker (36px) = 93px */
    max-width: 100%;
}

@media (max-width: 991.98px) {
    .stock-page-container {
        padding-top: 88px; /* compact mobile navbar (52px) + ticker (36px) = 88px */
        padding-left: 0;
        padding-right: 0;
    }
}

/* ============================================================
   Mobile Mini Price Bar — Groww/Zerodha style sticky top bar
   ============================================================ */
.mobile-mini-price-bar {
    display: none;
}

@media (max-width: 767.98px) {
    .mobile-mini-price-bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: fixed;
        top: 52px; /* below navbar */
        left: 0;
        right: 0;
        height: 44px;
        background: white;
        border-bottom: 1px solid var(--border-color);
        padding: 0 16px;
        z-index: 1015;
        transform: translateY(-100%);
        transition: transform 0.25s ease;
        box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    }

    .mobile-mini-price-bar.visible {
        transform: translateY(0);
    }

    .mini-price-symbol {
        font-weight: 700;
        font-size: 0.85rem;
        color: var(--secondary-color);
    }

    .mini-price-value {
        font-weight: 700;
        font-size: 0.95rem;
        color: var(--secondary-color);
    }

    .mini-price-change {
        font-size: 0.75rem;
        font-weight: 600;
        padding: 2px 8px;
        border-radius: 4px;
    }

    .mini-price-change.positive { background: #dcfce7; color: #15803d; }
    .mini-price-change.negative { background: #fee2e2; color: #b91c1c; }
}

/* ============================================================
   Base Desktop Styles
   ============================================================ */

.stock-sidebar {
    position: sticky;
    top: 140px;
    z-index: 100;
}

.sidebar-nav .nav-link {
    color: var(--text-body);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 2px;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    font-size: 0.9rem;
}

.sidebar-nav .nav-link:hover {
    background-color: var(--bg-alt);
    color: var(--primary-color);
}

.sidebar-nav .nav-link.active {
    background-color: #eff6ff;
    color: var(--primary-color);
    font-weight: 600;
}

.sidebar-nav .nav-link i {
    margin-right: 10px;
    font-size: 1rem;
}

.content-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-header-custom {
    background: white;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-soft);
}

.metric-card {
    background: var(--bg-body);
    border-radius: var(--radius-sm);
    padding: 16px;
    height: 100%;
    transition: all 0.2s;
    border: 1px solid var(--border-color);
}

.metric-card:hover {
    border-color: var(--primary-color);
    background: white;
}

.metric-label {
    color: var(--text-light);
    font-size: 0.7rem;
    font-weight: 700;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric-value {
    color: var(--secondary-color);
    font-size: 1.15rem;
    font-weight: 700;
}

.section-title {
    color: var(--secondary-color);
    font-weight: 600;
    margin-bottom: 20px;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
}

.section-title::before {
    content: '';
    display: block;
    width: 3px;
    height: 18px;
    background: var(--primary-color);
    margin-right: 10px;
    border-radius: 2px;
}

.stock-header-card {
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
    /* Not sticky on desktop — prevents large blank space gap */
    position: relative;
}

.stat-label {
    color: var(--text-light);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    margin-bottom: 2px;
}

.stat-value {
    color: var(--secondary-color);
    font-size: 1rem;
    font-weight: 600;
}

.stat-box {
    padding: 12px 16px;
}

/* Intraday Card */
.intraday-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.intraday-header {
    border-bottom: 1px solid var(--border-soft);
    padding-bottom: 12px;
}

.intraday-title {
    font-size: 0.9rem;
    color: var(--secondary-color);
}

/* ============================================================
   Mobile Stock Nav — Pill Scroller
   ============================================================ */

.mobile-stock-nav {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    padding: 10px 16px;
    background: white;
    border-bottom: 1px solid var(--border-color);
    margin: 0 -16px;  /* break out of container */
    scrollbar-width: none;
    position: sticky;
    top: 93px; /* below navbar + ticker */
    z-index: 900;
}

.mobile-stock-nav::-webkit-scrollbar {
    display: none;
}

.mobile-stock-nav .nav-link {
    white-space: nowrap;
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-light);
    border-radius: 20px;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    text-decoration: none;
    transition: all 0.2s;
    flex-shrink: 0;
}

.mobile-stock-nav .nav-link.active,
.mobile-stock-nav .nav-link:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* ============================================================
   App-Like Mobile Specific Overrides
   ============================================================ */

@media (max-width: 767.98px) {

    /* Page offset — below navbar + ticker + mobile-nav */
    .container.mt-30 {
        padding-top: 96px;
        padding-left: 12px;
        padding-right: 12px;
    }

    /* Stock header — compact app style, NOT sticky on mobile */
    .stock-header-card {
        border-radius: 0;
        border-left: none;
        border-right: none;
        margin-bottom: 0;
        position: relative !important; /* Override any sticky */
        top: auto !important;
        z-index: auto;
        box-shadow: none;
        border-top: none;
    }

    /* Stock title block */
    .stock-header-card .p-4 {
        padding: 14px 16px !important;
    }

    /* Stats grid — 3x2 on mobile */
    .stock-header-card .row.g-0.mt-4 {
        display: flex;
        flex-wrap: wrap;
        border-top: 1px solid var(--border-soft);
        margin-top: 12px !important;
        padding: 0;
    }

    .stock-header-card .col-6,
    .stock-header-card .col-md-2 {
        flex: 0 0 33.333333%;
        max-width: 33.333333%;
        width: 33.333333%;
        border-right: 1px solid var(--border-soft) !important;
        border-bottom: 1px solid var(--border-soft) !important;
    }

    /* Remove right border on every 3rd item */
    .stock-header-card .col-6:nth-child(3n),
    .stock-header-card .col-md-2:nth-child(3n) {
        border-right: none !important;
    }

    /* Remove bottom border on last 3 items */
    .stock-header-card .col-6:nth-last-child(-n+3),
    .stock-header-card .col-md-2:nth-last-child(-n+3) {
        border-bottom: none !important;
    }


    .stat-box {
        padding: 10px 14px;
    }

    .stat-value {
        font-size: 0.9rem;
    }

    .stat-label {
        font-size: 0.6rem;
    }

    /* Content cards — full-width bleed */
    .content-card {
        border-radius: 0;
        border-left: none;
        border-right: none;
        margin-left: -12px;
        margin-right: -12px;
        margin-bottom: 8px;
        box-shadow: none;
        border-bottom: 6px solid var(--bg-body); /* App-style divider */
    }

    .card-header-custom {
        padding: 14px 16px;
    }

    .section-title {
        font-size: 1rem;
        margin-bottom: 12px;
    }

    /* Metrics grid — 2 per row on mobile */
    .metric-card {
        padding: 12px;
        border-radius: 10px;
    }

    .metric-value {
        font-size: 1rem;
    }



    /* Chart height reduction for mobile */
    #tradingview_chart {
        height: 260px !important;
    }

    /* Row overrides for chart area */
    .content-card [style*="height: 500px"] {
        height: 260px !important;
    }

    /* Section content padding */
    .content-card .p-4 {
        padding: 16px !important;
    }

    /* Financials table — horizontal scroll */
    .table-responsive,
    [id$="-table-wrapper"] {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Hide sidebar on mobile */
    .col-lg-3.d-none.d-lg-block {
        display: none !important;
    }

    .col-lg-9 {
        width: 100% !important;
        max-width: 100%;
        flex: 0 0 100%;
    }
}

/* ============================================================
   Tablet (iPad) overrides
   ============================================================ */

@media (min-width: 768px) and (max-width: 991.98px) {
    .stock-header-card {
        top: 92px;
    }

    .mobile-stock-nav {
        top: 152px;
    }

    .content-card .p-4 {
        padding: 20px !important;
    }

    .col-lg-9 {
        width: 100%;
        max-width: 100%;
        flex: 0 0 100%;
    }

    .col-lg-3 {
        display: none !important;
    }
}
