/* Add at top of <style> block in stock_detail.html (after line 6) */
body,
.main-content {
    background: #ffffff !important;
}

/* Override inline gradient styles */
[style*="linear-gradient"] {
    background: transparent !important;
    color: #111827 !important;
    border: 1px solid #e5e7eb !important;
}

/* Clean card headers */
.card-header {
    background: #f9fafb !important;
    border-bottom: 1px solid #e5e7eb !important;
}


/* Fix Font Awesome icons */
.fa, .fas, .far, .fab {
    font-family: "Font Awesome 6 Free" !important;
    font-weight: 900;
}

.fa::before, .fas::before, .far::before, .fab::before {
    font-family: "Font Awesome 6 Free" !important;
}

/* Hide Firefox generated content */
._moz_generated_content_before {
    display: none !important;
}


/* Dynamic Stock Detail Card Grid - ALWAYS 3 cards per row on desktop/tablet */
.stock-detail-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
    align-items: stretch;
}

.dashboard-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--card-bg, #ffffff);
    backdrop-filter: blur(10px);
    padding: 1rem 0;
    margin-bottom: 1.5rem !important;
    border-bottom: 2px solid rgba(102, 126, 234, 0.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* 2. REDUCE HERO CARD HEIGHT ON MOBILE */
@media (max-width: 767px) {
    /* Price Card - Reduced height */
    .card.shadow-sm.mb-4[style*="background"] {
        padding: 1rem !important;
    }

    .card.shadow-sm.mb-4[style*="background"] .card-body {
        padding: 1rem !important;
    }

    .card.shadow-sm.mb-4[style*="background"] h2 {
        font-size: 2rem !important;
        margin-bottom: 0.5rem !important;
    }

    .card.shadow-sm.mb-4[style*="background"] p {
        font-size: 1rem !important;
        margin-bottom: 0.5rem !important;
    }

    .card.shadow-sm.mb-4[style*="background"] small {
        font-size: 0.75rem !important;
    }
}

/* 3. BADGE WRAPPING - Make badges wrap properly */
@media (max-width: 767px) {
    /* Header badges */
    .dashboard-header .lead {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .dashboard-header .badge {
        white-space: nowrap;
        font-size: 0.75rem;
        padding: 0.35rem 0.6rem;
        margin: 0 !important;
    }

    /* Company info badges */
    .card-body .badge {
        font-size: 0.75rem;
        padding: 0.35rem 0.6rem;
        margin-bottom: 0.5rem;
        display: inline-block;
    }

    /* Pattern/Sentiment badges in tables */
    table .badge {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
        white-space: nowrap;
    }
}

/* Chart responsive adjustments */
@media (max-width: 767px) {
    #stock-charts {
        height: 600px !important;
    }

    .js-plotly-plot .plotly .modebar {
        left: 0 !important;
    }
}


/* 4. BUTTON SIZING ON MOBILE */
@media (max-width: 767px) {
    /* Back to Search button */
    .dashboard-header .btn {
        font-size: 0.85rem;
        padding: 0.5rem 1rem;
        white-space: nowrap;
    }

    /* Table action buttons */
    .btn-sm {
        font-size: 0.75rem;
        padding: 0.35rem 0.7rem;
    }

    /* Chart view buttons */
    .btn-outline-primary {
        font-size: 0.75rem;
        padding: 0.35rem 0.7rem;
    }

    /* Stack header buttons vertically on very small screens */
    @media (max-width: 400px) {
        .dashboard-header {
            flex-direction: column !important;
            align-items: flex-start !important;
        }

        .dashboard-header > div:last-child {
            margin-top: 1rem;
            width: 100%;
        }

        .dashboard-header .btn {
            width: 100%;
            justify-content: center;
        }
    }
}

/* 5. MOBILE TABLE IMPROVEMENTS */
@media (max-width: 767px) {
    /* Make tables scroll horizontally */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }

    /* Improve table cell padding */
    .table td, .table th {
        padding: 0.5rem;
        font-size: 0.85rem;
    }

    /* Headline cells should wrap */
    td[style*="max-width"] {
        max-width: 200px !important;
        font-size: 0.8rem;
        line-height: 1.3;
    }
}

/* 6. CARD SPACING ON MOBILE */
@media (max-width: 767px) {
    /* Reduce spacing between cards */
    .card.shadow-sm {
        margin-bottom: 1rem !important;
    }

    /* Reduce grid gap */
    .stock-detail-grid {
        gap: 1rem !important;
    }

    /* Card padding */
    .card-body {
        padding: 1rem;
    }

    .card-header h5 {
        font-size: 1rem;
    }
}

/* 7. PRICE DISPLAY OPTIMIZATION */
@media (max-width: 767px) {
    /* Stack price info vertically */
    .card.shadow-sm.mb-4[style*="background"] .row {
        flex-direction: column;
    }

    .card.shadow-sm.mb-4[style*="background"] .text-right {
        text-align: left !important;
        margin-top: 1rem;
    }
}

/* 8. IMPROVE TOUCH TARGETS */
@media (max-width: 767px) {
    /* Minimum touch target size 44x44px (Apple HIG) */
    a, button, .btn {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Table links */
    table a {
        padding: 0.5rem;
    }
}

/* 9. HIDE LESS IMPORTANT INFO ON SMALL SCREENS */
@media (max-width: 576px) {
    /* Hide some secondary metrics in price card */
    .card.shadow-sm.mb-4[style*="background"] small span:not(:first-child) {
        display: none;
    }

    /* Show a "+ more" indicator */
    .card.shadow-sm.mb-4[style*="background"] small::after {
        content: ' + more';
        opacity: 0.7;
    }
}

/* 10. SMOOTH SCROLL BEHAVIOR */
html {
    scroll-behavior: smooth;
}

/* Offset for sticky header when jumping to anchors */
:target {
    scroll-margin-top: 100px;
}

/* Mobile only - 1 card per row */
@media (max-width: 767px) {
    .stock-detail-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 767px) {
    .dashboard-header .btn {
        display: none;
    }
}

/* Ensure cards have equal heights */
.stock-detail-grid .card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.stock-detail-grid .card .card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem;
}

/* Reduce padding in cards for more compact layout */
.stock-detail-grid .card .card-header {
    padding: 0.75rem 1rem;
}

.stock-detail-grid .card .card-header h5 {
    font-size: 1rem;
    margin-bottom: 0;
}

/* Print Styles */
@media print {
    /* Hide navigation, sidebar, and export buttons */
    nav, .sidebar, .dashboard-header .btn-group,
    .btn, .navbar, footer {
        display: none !important;
    }

    /* Show only the main content */
    .container-fluid {
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Ensure cards print properly */
    .card {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* Remove shadows and backgrounds for printing */
    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }

    /* Optimize table printing */
    .table {
        font-size: 0.85rem;
    }

    /* Ensure charts are visible */
    #stock-charts {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* Remove gradients for printing */
    .card-header {
        background: #f8f9fa !important;
        color: #000 !important;
    }

    /* Optimize spacing for printing */
    .stock-detail-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 1rem !important;
    }

    /* Hide plotly modebar in print */
    .modebar {
        display: none !important;
    }
}

/* Featured In Widget Hover Effect */
.hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15) !important;
}


/* Share link toast notification */
.share-link-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #28a745;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 5px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    display: none;
}

/* Grade badge styling */
.grade-badge {
    font-weight: bold;
    border-radius: 10px;
    display: inline-block;
    text-align: center;
}

/* Clickable metric links with cool hover */
.metric-link {
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
    display: inline-block;
}

.metric-link:hover {
    color: #007bff;
    text-decoration: none;
    transform: translateX(5px);
}

.metric-link:hover .fa-info-circle {
    color: #007bff !important;
}

/* Grade badge colors - Maximum specificity to override Bootstrap and any inline styles */
.card-body .badge.grade-badge.grade-a,
.card-body div.grade-badge.grade-a,
div.badge.grade-badge.grade-a {
    background-color: #28a745 !important; /* Green - Excellent */
    color: white !important;
    border: none !important;
}

.card-body .badge.grade-badge.grade-b,
.card-body div.grade-badge.grade-b,
div.badge.grade-badge.grade-b {
    background-color: #17a2b8 !important; /* Teal/Blue - Good/Neutral */
    color: white !important;
    border: none !important;
}

.card-body .badge.grade-badge.grade-c,
.card-body div.grade-badge.grade-c,
div.badge.grade-badge.grade-c {
    background-color: #ffc107 !important; /* Yellow - Average */
    color: #212529 !important;
    border: none !important;
}

.card-body .badge.grade-badge.grade-d,
.card-body div.grade-badge.grade-d,
div.badge.grade-badge.grade-d {
    background-color: #fd7e14 !important; /* Orange - Below Average */
    color: white !important;
    border: none !important;
}

.card-body .badge.grade-badge.grade-e,
.card-body div.grade-badge.grade-e,
div.badge.grade-badge.grade-e {
    background-color: #dc3545 !important; /* Red - Poor */
    color: white !important;
    border: none !important;
}

.card-body .badge.grade-badge.grade-f,
.card-body div.grade-badge.grade-f,
div.badge.grade-badge.grade-f {
    background-color: #6f1e1e !important; /* Dark Red - Very Poor */
    color: white !important;
    border: none !important;
}

.card-body .badge.grade-badge.grade-na,
.card-body div.grade-badge.grade-na,
div.badge.grade-badge.grade-na {
    background-color: #6c757d !important;
    color: white !important;
    border: none !important;
}

.component-score-item {
    padding: 0.5rem 0;
}

.component-score-item .progress {
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
    background-color: #e9ecef;
}

.component-score-item .progress-bar {
    font-weight: 600;
    transition: width 0.6s ease;
}

.font-weight-medium {
    font-weight: 500;
}

.badge-sm {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

.metric-box {
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 5px;
    text-align: center;
}

/* Exclude Sector Comparison table from DataTables */
#sector-comparison-table {
    /* This table should not use DataTables */
}

/* ============================================
   MODERN TABLE STYLING FOR ALL CARDS
   ============================================ */
.stock-detail-table {
    width: 100%;
    margin-bottom: 0;
    font-size: 0.9rem;
}

.stock-detail-table thead {
    background: transparent;
    border-bottom: 2px solid #e9ecef;
}

.stock-detail-table thead th {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6c757d;
    padding: 0.75rem 0.5rem;
    border: none;
}

.stock-detail-table tbody tr {
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
}

.stock-detail-table tbody tr:hover {
    background-color: #f8f9fa;
}

.stock-detail-table tbody tr:last-child {
    border-bottom: none;
}

.stock-detail-table tbody td {
    padding: 0.6rem 0.5rem;
    vertical-align: middle;
    border: none;
}

.stock-detail-table tbody td:first-child {
    font-weight: 500;
    color: #495057;
}

.stock-detail-table tbody td:last-child {
    font-weight: 600;
    text-align: right;
    vertical-align: middle;
    white-space: nowrap;
}

/* Status badges inline with values - single line */
.stock-detail-table tbody td:last-child .metric-status {
    display: inline-block;
    margin-left: 0.5rem;
    vertical-align: middle;
}

/* Metric label styling */
.metric-label {
    font-size: 0.85rem;
    color: #6c757d;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.metric-label i {
    font-size: 0.75rem;
    opacity: 0.7;
}

/* Metric value styling */
.metric-value {
    font-size: 1rem;
    font-weight: 600;
    white-space: nowrap;
}

.metric-value-large {
    font-size: 1.25rem;
    font-weight: 700;
}

/* Status badges for metrics */
.metric-status {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-weight: 500;
    display: inline-block;
    margin-top: 0.25rem;
    white-space: nowrap;
}

.metric-status-success {
    background-color: #d4edda;
    color: #155724;
}

.metric-status-warning {
    background-color: #fff3cd;
    color: #856404;
}

.metric-status-danger {
    background-color: #f8d7da;
    color: #721c24;
}

.metric-status-info {
    background-color: #d1ecf1;
    color: #0c5460;
}

/* Ensure status badges don't break to new line */
.stock-detail-table tbody td:last-child > div[style*="display: flex"] {
    flex-wrap: nowrap;
    white-space: nowrap;
}

/* Section headers within cards */
.card-section-header {
    font-size: 0.85rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.5rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-section-header i {
    font-size: 0.85rem;
    opacity: 0.8;
}

/* Divider styling */
.card-divider {
    margin: 0.75rem 0;
    border: none;
    border-top: 1px solid #e9ecef;
}

/* Info footer styling */
.card-info-footer {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background-color: #f8f9fa;
    border-radius: 6px;
    font-size: 0.7rem;
    color: #6c757d;
}

/* Highlight row for important metrics */
.stock-detail-table tbody tr.highlight-row {
    background-color: #f0f7ff;
    border-left: 3px solid #3b82f6;
}

.stock-detail-table tbody tr.highlight-row:hover {
    background-color: #e0efff;
}
