/**
 * SIGMIX - Sectors Page Styles v3.1
 * /css/sectors.css
 * Enhanced with real-time performance indicators
 */

/* ========================================
   UTILITIES
======================================== */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.up { color: #059669 !important; }
.down { color: #DC2626 !important; }

/* ========================================
   HEADER SPACER
======================================== */
.header-spacer { height: 70px; }

/* ========================================
   SECONDARY NAVIGATION
======================================== */


/* ========================================
   PAGE HEADER (All Sectors View)
======================================== */
.page-header {
    padding: 2rem 0 1.5rem;
    background: var(--off-white);
    border-bottom: 1px solid var(--gray-200);
}
.page-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    flex-wrap: wrap;
}
.page-header-text h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--dark);
    margin-bottom: 0.25rem;
    line-height: 1.2;
}
.page-header-text h1 span {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.page-header-text p {
    font-size: 0.95rem;
    color: var(--gray);
    max-width: 500px;
}
.page-header-text .last-updated {
    font-size: 0.8rem;
    color: var(--gray);
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.page-header-text .last-updated i { color: var(--primary); }

.header-stats {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}
.header-stat {
    text-align: center;
    padding: 0.75rem 1.25rem;
    background: var(--white);
    border-radius: 12px;
    border: 1px solid var(--gray-200);
    min-width: 85px;
}
.header-stat strong {
    display: block;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.2;
}
.header-stat strong.accent { color: var(--accent); }
.header-stat strong.up { color: #059669; }
.header-stat strong.down { color: #DC2626; }
.header-stat span {
    font-size: 0.7rem;
    color: var(--gray);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ========================================
   MAIN CONTENT
======================================== */
.sectors-content {
    padding: 2rem 0 3rem;
    background: var(--white);
}

/* ========================================
   SECTORS GRID (Enhanced)
======================================== */
.sectors-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
}

.sector-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 16px;
    padding: 1.25rem;
    text-decoration: none;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}
.sector-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gray-200);
    transition: background 0.3s;
}
.sector-card.sector-up::before { background: linear-gradient(90deg, #10B981, #34D399); }
.sector-card.sector-down::before { background: linear-gradient(90deg, #EF4444, #F87171); }

.sector-card:hover,
.sector-card:focus {
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(7, 0, 120, 0.12);
}

.sector-card-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.75rem;
}
.sector-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sector-icon i {
    color: var(--white);
    font-size: 1.15rem;
}
.sector-title-group { flex: 1; min-width: 0; }
.sector-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 0.15rem;
    line-height: 1.3;
}
.sector-title-ar {
    font-size: 0.8rem;
    color: var(--gray);
}

/* Sector Performance Badge */
.sector-performance {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--gray-200);
}
.sector-change {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1;
}
.sector-change.up { color: #059669; }
.sector-change.down { color: #DC2626; }
.sector-change-label {
    font-size: 0.7rem;
    color: var(--gray);
    text-transform: uppercase;
    font-weight: 600;
}

.sector-stats {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
}
.sector-stat {
    text-align: center;
    flex: 1;
}
.sector-stat-value {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
}
.sector-stat-value.up { color: #059669; }
.sector-stat-value.down { color: #DC2626; }
.sector-stat-label {
    font-size: 0.65rem;
    color: var(--gray);
    text-transform: uppercase;
    margin-top: 0.2rem;
    letter-spacing: 0.3px;
}

.sector-mcap {
    font-size: 0.75rem;
    color: var(--gray);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding-top: 0.5rem;
    border-top: 1px dashed var(--gray-200);
}
.sector-mcap i { color: var(--accent); }

.sector-arrow {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-top: auto;
    padding-top: 0.75rem;
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 600;
    opacity: 0;
    transform: translateX(-10px);
    transition: all 0.3s ease;
}
.sector-card:hover .sector-arrow,
.sector-card:focus .sector-arrow {
    opacity: 1;
    transform: translateX(0);
}
.sector-arrow i {
    margin-left: 0.4rem;
    transition: transform 0.3s ease;
}
.sector-card:hover .sector-arrow i { transform: translateX(4px); }

/* ========================================
   SECTOR DETAIL HEADER - Improved Design
======================================== */
.sector-detail-header {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #fff;
    padding: 2rem 0 2.5rem;
    position: relative;
}

/* Remove red/green background variants - use neutral dark */
.sector-detail-header.positive,
.sector-detail-header.negative {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

.sector-detail-header .back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
    transition: color 0.2s;
}

.sector-detail-header .back-link:hover {
    color: #fff;
}

.sector-detail-inner {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.sector-detail-icon {
    width: 70px;
    height: 70px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    color: #fff;
    flex-shrink: 0;
}

.sector-detail-info {
    flex: 1;
    min-width: 250px;
}

.sector-detail-info h1 {
    font-size: 1.75rem;
    font-weight: 800;
    margin: 0 0 0.25rem;
    color: #fff;
}

.sector-name-ar {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.6);
    margin: 0 0 0.75rem;
}

.sector-detail-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.sector-detail-meta .meta-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.8);
}

.sector-detail-meta .meta-item i {
    font-size: 0.75rem;
    opacity: 0.7;
}

/* Change Badge - Pill Style with Clear Colors */
.sector-detail-meta .change-badge {
    padding: 0.4rem 0.85rem;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.8rem;
}

.sector-detail-meta .change-badge.positive {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.sector-detail-meta .change-badge.negative {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Stats Cards - Neutral Background */
.sector-detail-stats {
    display: flex;
    gap: 0.75rem;
    margin-left: auto;
}

.detail-stat {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 0.75rem 1.25rem;
    text-align: center;
    min-width: 80px;
}

.detail-stat .stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    display: block;
    line-height: 1.2;
}

.detail-stat .stat-value.up {
    color: #6ee7b7;
}

.detail-stat .stat-value.down {
    color: #fca5a5;
}

.detail-stat .stat-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 0.25rem;
}

/* Last Updated */
.sector-detail-header .last-updated {
    margin-top: 1.25rem;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
}

.sector-detail-header .last-updated i {
    margin-right: 0.35rem;
}

/* ========================================
   RESPONSIVE
======================================== */
@media (max-width: 768px) {
    .sector-detail-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .sector-detail-stats {
        margin-left: 0;
        width: 100%;
        justify-content: flex-start;
    }
    
    .detail-stat {
        flex: 1;
        min-width: 0;
    }
    
    .sector-detail-info h1 {
        font-size: 1.5rem;
    }
}

.sector-detail-header .last-updated {
    margin-top: 1rem;
    font-size: 0.8rem;
    opacity: 0.7;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* ========================================
   STOCKS MOBILE LIST (Sector Detail)
======================================== */
.stocks-mobile-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.stock-mobile-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
}
.stock-mobile-card:hover { border-color: var(--primary); }
.stock-mobile-logo img {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    object-fit: contain;
    background: var(--off-white);
}
.stock-mobile-info { flex: 1; min-width: 0; }
.stock-mobile-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.stock-mobile-meta {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.2rem;
}
.stock-mobile-symbol {
    font-size: 0.7rem;
    color: var(--primary);
    font-weight: 700;
    font-family: monospace;
}
.shariah-tag {
    font-size: 0.6rem;
    color: var(--accent);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.2rem;
}
.stock-mobile-price { text-align: right; }
.stock-mobile-price .price {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--dark);
    display: block;
}
.stock-mobile-price .change {
    font-size: 0.8rem;
    font-weight: 700;
}
.stock-mobile-price .change.up { color: #059669; }
.stock-mobile-price .change.down { color: #DC2626; }

/* ========================================
   STOCKS TABLE (Sector Detail Desktop)
======================================== */
.stocks-table-wrapper {
    display: none;
    overflow-x: auto;
}
.stocks-table {
    width: 100%;
    background: var(--white);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--gray-200);
    border-collapse: collapse;
}
.stocks-table th {
    background: var(--primary);
    color: var(--white);
    padding: 1rem 1.25rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
.stocks-table th:first-child { border-radius: 16px 0 0 0; }
.stocks-table th:last-child { border-radius: 0 16px 0 0; }
.stocks-table td {
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--gray-200);
    font-size: 0.9rem;
    vertical-align: middle;
}
.stocks-table tbody tr:last-child td { border-bottom: none; }
.stocks-table tbody tr:hover td { background: var(--off-white); }

.stock-cell {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.stock-logo-sm {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--off-white);
    border: 1px solid var(--gray-200);
}
.stock-logo-sm img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.stock-name-cell strong {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--dark);
}
.stock-name-ar {
    font-size: 0.75rem;
    color: var(--gray);
    display: block;
    margin-top: 0.1rem;
}

.symbol-code {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary);
    background: rgba(7,0,120,0.06);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.price-cell { font-weight: 700; }
.change-cell { font-weight: 700; }
.change-cell.up { color: #059669; }
.change-cell.down { color: #DC2626; }

.trend-badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
}
.trend-badge.trend-uptrend { background: rgba(16,185,129,0.15); color: #059669; }
.trend-badge.trend-downtrend { background: rgba(239,68,68,0.15); color: #DC2626; }
.trend-badge.trend-sideways, .trend-badge.trend-n\/a { background: var(--gray-200); color: var(--gray); }

.shariah-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.7rem;
    color: var(--accent);
    font-weight: 600;
    background: rgba(16, 185, 129, 0.1);
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
}
.type-badge { color: var(--gray); }

.view-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.8rem;
    transition: gap 0.2s ease;
}
.view-link:hover,
.view-link:focus {
    text-decoration: underline;
    gap: 0.6rem;
}

/* ========================================
   EMPTY STATE
======================================== */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--gray);
}
.empty-state i {
    font-size: 3rem;
    opacity: 0.4;
    margin-bottom: 1rem;
}
.empty-state h3 {
    font-size: 1.25rem;
    color: var(--dark);
    margin-bottom: 0.5rem;
}
.empty-state p { margin-bottom: 1.5rem; }
.empty-state .btn-back {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--primary);
    color: var(--white);
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
}
.empty-state .btn-back:hover { background: var(--primary-light); }

/* ========================================
   FAQ SECTION
======================================== */
.faq-section {
    padding: 2.5rem 0;
    background: var(--off-white);
    border-top: 1px solid var(--gray-200);
}
.faq-section h2 {
    font-size: 1.25rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--dark);
}
.faq-section h2 i { color: var(--primary); }
.faq-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}
.faq-item {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    padding: 1.25rem;
}
.faq-item h3 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--dark);
}
.faq-item p {
    font-size: 0.85rem;
    color: var(--gray);
    line-height: 1.5;
}

/* ========================================
   CTA SECTION
======================================== */
.cta-section {
    padding: 3rem 0;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
}
.cta-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    flex-wrap: wrap;
}
.cta-text { color: var(--white); }
.cta-text h2 {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 0.25rem;
}
.cta-text p {
    font-size: 0.95rem;
    opacity: 0.9;
}
.cta-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.cta-btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.75rem;
    background: var(--white);
    color: var(--primary);
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    transition: all 0.3s ease;
}
.cta-btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2); }
.cta-btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.75rem;
    background: transparent;
    color: var(--white);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    transition: all 0.3s ease;
}
.cta-btn-secondary:hover { background: rgba(255, 255, 255, 0.1); border-color: var(--white); }

/* ========================================
   RESPONSIVE
======================================== */
@media (min-width: 768px) {
    .stocks-mobile-list { display: none; }
    .stocks-table-wrapper { display: block; }
}

@media (max-width: 1200px) {
    .sectors-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {

    .page-header-inner {
        flex-direction: column;
        text-align: center;
    }
    .page-header-text .last-updated { justify-content: center; }
    .page-header-text p { max-width: 100%; }
    .header-stats { justify-content: center; }
    .sectors-grid { grid-template-columns: 1fr; gap: 1rem; }
    .sector-detail-inner { flex-direction: column; text-align: center; }
    .sector-detail-meta { justify-content: center; }
    .sector-detail-stats { justify-content: center; }
    .back-link { justify-content: center; }
    .faq-grid { grid-template-columns: 1fr; }
    .cta-inner { flex-direction: column; text-align: center; }
    .cta-buttons { justify-content: center; }
}

@media (max-width: 480px) {
    .header-stats { flex-wrap: wrap; gap: 0.75rem; }
    .header-stat { flex: 1; min-width: 75px; padding: 0.6rem 0.75rem; }
    .header-stat strong { font-size: 1.25rem; }
    .sector-detail-stats { flex-wrap: wrap; gap: 0.75rem; }
    .detail-stat { flex: 1; min-width: 70px; }
    .cta-buttons { flex-direction: column; width: 100%; }
    .cta-btn-primary, .cta-btn-secondary { justify-content: center; }
}

/* ========================================
   PRINT STYLES
======================================== */
@media print {
    .cta-section, .sector-arrow, .faq-section { display: none; }
    .sectors-grid { grid-template-columns: repeat(2, 1fr); }
    .sector-card { break-inside: avoid; box-shadow: none; border: 1px solid #ccc; }
}

/* Clickable Stock Cell */
a.stock-cell {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: inherit;
    transition: opacity 0.2s;
}

a.stock-cell:hover {
    opacity: 0.8;
}

a.stock-cell:hover strong {
    color: var(--primary);
    text-decoration: underline;
}

/* Remove market cap styles (optional cleanup) */
.sector-mcap {
    display: none;
}


/* ========================================
   SECTOR DETAIL HEADER - FORCE FIX
   (Add at very end of file to override)
======================================== */
.sector-detail-header,
.sector-detail-header.positive,
.sector-detail-header.negative,
header.sector-detail-header {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%) !important;
}

/* Change badge - ensure visibility on dark background */
.sector-detail-meta .change-badge {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
}

.sector-detail-meta .change-badge.positive {
    background: rgba(16, 185, 129, 0.2) !important;
    color: #6ee7b7 !important;
    border-color: rgba(16, 185, 129, 0.4) !important;
}

.sector-detail-meta .change-badge.negative {
    background: rgba(239, 68, 68, 0.2) !important;
    color: #fca5a5 !important;
    border-color: rgba(239, 68, 68, 0.4) !important;
}

/* Stat cards on dark header */
.sector-detail-stats .detail-stat {
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
}

.sector-detail-stats .detail-stat .stat-value {
    color: #fff;
}

.sector-detail-stats .detail-stat .stat-value.up {
    color: #6ee7b7 !important;
}

.sector-detail-stats .detail-stat .stat-value.down {
    color: #fca5a5 !important;
}

.sector-detail-stats .detail-stat .stat-label {
    color: rgba(255, 255, 255, 0.6) !important;
}