/* ===================================================
   Transparency Center — مركز الشفافية
   Premium Dark Theme with Gold Accents
   =================================================== */

@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800&display=swap');

/* ===== CSS Variables ===== */
:root {
    --bg-primary: #180509;
    --bg-secondary: #24090E;
    --bg-card: rgba(36, 9, 14, 0.65);
    --bg-card-hover: rgba(50, 13, 20, 0.8);
    --bg-glass: rgba(132, 42, 59, 0.04);
    --gold: #842A3B;
    --gold-light: #C57E8F;
    --gold-dark: #4A1521;
    --gold-glow: rgba(132, 42, 59, 0.15);
    --text: #F7E0BF;
    --text-muted: #D5B8C0;
    --text-dim: #9C727D;
    --border: rgba(247, 224, 191, 0.12);
    --border-hover: rgba(247, 224, 191, 0.25);
    --success: #2E7D32;
    --danger: #C62828;
    --info: #1565C0;
    --radius: 16px;
    --radius-sm: 10px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    --shadow-gold: 0 4px 20px rgba(132, 42, 59, 0.25);
    --bg-card-gradient: linear-gradient(135deg, rgba(36, 9, 14, 0.75), rgba(24, 5, 9, 0.85));
}

/* ===== Light Theme Overrides ===== */
body.light-theme {
    --bg-primary: #FDF8F0;
    --bg-secondary: #F5EDE0;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-card-hover: rgba(255, 255, 255, 0.95);
    --bg-glass: rgba(132, 42, 59, 0.03);
    
    --gold: #842A3B;
    --gold-light: #A95368;
    --gold-dark: #4A1521;
    --gold-glow: rgba(132, 42, 59, 0.08);
    
    --text: #2C1810;
    --text-muted: #6E5C55;
    --text-dim: #9C8982;
    
    --border: rgba(132, 42, 59, 0.12);
    --border-hover: rgba(132, 42, 59, 0.25);
    
    --success: #2E7D32;
    --danger: #D32F2F;
    --info: #1976D2;
    
    --shadow: 0 8px 32px rgba(62, 31, 28, 0.08);
    --shadow-gold: 0 4px 20px rgba(132, 42, 59, 0.12);
    --bg-card-gradient: linear-gradient(135deg, rgba(255, 255, 255, 0.85), rgba(245, 237, 224, 0.9));
    
    background: radial-gradient(circle at 50% 0%, #FDF8F0 0%, #EADDC9 90%) fixed;
}

/* FIX #1: previously this rule *replaced* the base recolor filter instead of
   extending it, so the logo lost its invert/sepia/hue-rotate recoloring in
   light mode. Now it keeps the same recolor chain (retuned for a light
   background) plus its own drop-shadow. */
body.light-theme .tc-header-logo img {
    filter: invert(1) sepia(1) saturate(2.5) hue-rotate(345deg) brightness(0.75) contrast(1.15)
            drop-shadow(0 4px 12px rgba(62, 31, 28, 0.18));
}

body.light-theme .tc-header-logo img:hover {
    transform: scale(1.05);
    filter: invert(1) sepia(1) saturate(3.5) hue-rotate(345deg) brightness(0.8) contrast(1.25)
            drop-shadow(0 6px 18px rgba(62, 31, 28, 0.28));
}

body.light-theme .bg-orb-1 {
    background: radial-gradient(circle, rgba(132, 42, 59, 0.08), transparent 70%);
}

body.light-theme .bg-orb-2 {
    background: radial-gradient(circle, rgba(197, 126, 143, 0.08), transparent 70%);
}

body.light-theme .bg-orb-3 {
    background: radial-gradient(circle, rgba(247, 224, 191, 0.2), transparent 70%);
}

body.light-theme .tc-progress-bar {
    background: rgba(132, 42, 59, 0.06);
}

body.light-theme .tc-ranking-table thead th {
    background: rgba(132, 42, 59, 0.03);
}

body.light-theme .tc-ranking-table tbody tr:hover {
    background: rgba(132, 42, 59, 0.04);
}


/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
    background: radial-gradient(circle at 50% 0%, var(--gold-dark) 0%, var(--bg-primary) 85%) fixed;
    color: var(--text);
    line-height: 1.7;
    min-height: 100vh;
    overflow-x: hidden;
}

body.ltr {
    direction: ltr;
    text-align: left;
}

body:not(.ltr) {
    direction: rtl;
    text-align: right;
}

/* ===== Background Decoration ===== */
.bg-decoration {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.bg-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.35;
    animation: orbFloat 20s ease-in-out infinite alternate;
    will-change: transform;
}

.bg-orb-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(132, 42, 59, 0.18), transparent 70%);
    top: -10%;
    right: -5%;
}

.bg-orb-2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(74, 21, 33, 0.25), transparent 70%);
    bottom: -5%;
    left: -5%;
    animation-delay: -10s;
}

.bg-orb-3 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(247, 224, 191, 0.08), transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -5s;
}

@keyframes orbFloat {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(30px, -20px) scale(1.1); }
    100% { transform: translate(-20px, 15px) scale(0.95); }
}

/* ===== Container ===== */
.page-container {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}

/* ===== Header ===== */
.tc-header {
    text-align: center;
    padding: 40px 20px 30px;
    position: relative;
}

.tc-header-logo img {
    width: 240px;
    height: auto;
    filter: invert(1) sepia(1) saturate(2.5) hue-rotate(345deg) brightness(0.9) contrast(1.1)
            drop-shadow(0 0 10px rgba(247, 224, 191, 0.45)) 
            drop-shadow(0 2px 20px rgba(132, 42, 59, 0.65));
    margin-bottom: 16px;
    transition: var(--transition);
}

.tc-header-logo img:hover {
    transform: scale(1.05);
    filter: invert(1) sepia(1) saturate(3.5) hue-rotate(345deg) brightness(1) contrast(1.2)
            drop-shadow(0 0 15px rgba(247, 224, 191, 0.65)) 
            drop-shadow(0 2px 25px rgba(132, 42, 59, 0.85));
}

.tc-header h1 {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--gold), var(--gold-light), #fff, var(--gold));
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 4s ease-in-out infinite;
    margin-bottom: 8px;
}

@keyframes shimmer {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.tc-header p {
    color: var(--text-muted);
    font-size: 1rem;
    max-width: 500px;
    margin: 0 auto;
}

.tc-header-divider {
    width: 80px;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    margin: 20px auto 0;
    border-radius: 2px;
}

/* ===== Controls Bar ===== */
.tc-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.tc-lang-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border: 1px solid var(--border);
    border-radius: 30px;
    background: var(--bg-card);
    color: var(--gold-light);
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.tc-lang-btn:hover {
    background: linear-gradient(135deg, rgba(132, 42, 59, 0.2), rgba(197, 126, 143, 0.1));
    border-color: var(--gold-light);
    transform: translateY(-1px);
}

.tc-theme-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 22px;
    border: 1px solid var(--gold-light);
    border-radius: 30px;
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    color: #FFFFFF;
    font-family: inherit;
    font-weight: 700;
    font-size: 0.88rem;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(132, 42, 59, 0.4);
}

.tc-theme-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(132, 42, 59, 0.55);
    background: linear-gradient(135deg, var(--gold-light), var(--gold));
    border-color: #FFFFFF;
}

.tc-live-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(39, 174, 96, 0.1);
    border: 1px solid rgba(39, 174, 96, 0.2);
    border-radius: 30px;
    color: var(--success);
    font-size: 0.8rem;
    font-weight: 500;
}

.tc-live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

.tc-last-update {
    color: var(--text-dim);
    font-size: 0.78rem;
}

/* ===== Overview Cards Grid ===== */
.tc-overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.tc-stat-card {
    background: var(--bg-card-gradient);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 18px;
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

.tc-stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    opacity: 0;
    transition: var(--transition);
}

.tc-stat-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-hover);
    box-shadow: var(--shadow-gold);
}

.tc-stat-card:hover::before {
    opacity: 1;
}

.tc-stat-icon {
    margin-bottom: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.tc-stat-value {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--gold);
    line-height: 1.2;
    margin-bottom: 4px;
}

.tc-stat-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* ===== Chart Sections ===== */
.tc-section {
    margin-bottom: 28px;
}

.tc-card {
    background: var(--bg-card-gradient);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    position: relative;
    overflow: hidden;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    transition: var(--transition);
}

.tc-card:hover {
    border-color: var(--border-hover);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* FIX #3: this was previously declared twice (here, and again further down
   in the "SVG Icons Styling" section) with conflicting `gap` values.
   Consolidated into a single rule. */
.tc-card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.tc-card-title span {
    font-size: 1.2rem;
}

/* Chart containers */
.tc-chart-container {
    position: relative;
    width: 100%;
    max-height: 350px;
}

.tc-chart-container canvas {
    max-height: 350px;
}

/* ===== Charts Row (2-column) ===== */
.tc-charts-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 28px;
}

/* ===== Ranking Table ===== */
.tc-ranking-table {
    width: 100%;
    border-collapse: collapse;
}

.tc-ranking-table thead th {
    padding: 12px 14px;
    text-align: right;
    color: var(--gold-light);
    font-weight: 600;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
    background: rgba(247, 224, 191, 0.04);
}

body.ltr .tc-ranking-table thead th {
    text-align: left;
}

.tc-ranking-table tbody tr {
    transition: var(--transition);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.tc-ranking-table tbody tr:hover {
    background: rgba(132, 42, 59, 0.08);
}

.tc-ranking-table tbody td {
    padding: 11px 14px;
    font-size: 0.9rem;
}

.tc-rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.82rem;
}

.tc-rank-1 {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #333;
}

.tc-rank-2 {
    background: linear-gradient(135deg, #C0C0C0, #A8A8A8);
    color: #333;
}

.tc-rank-3 {
    background: linear-gradient(135deg, #CD7F32, #A0522D);
    color: #fff;
}

.tc-rank-default {
    background: var(--bg-secondary);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.tc-progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(247, 224, 191, 0.1);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 4px;
}

.tc-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--gold-dark), var(--gold), var(--gold-light));
    border-radius: 3px;
    transition: width 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.tc-percentage {
    display: inline-block;
    padding: 2px 10px;
    background: linear-gradient(135deg, rgba(132, 42, 59, 0.2), rgba(197, 126, 143, 0.1));
    color: var(--gold-light);
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 600;
}

/* ===== Insights Grid ===== */
.tc-insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.tc-insight-item {
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 18px 16px;
    text-align: center;
    transition: var(--transition);
}

.tc-insight-item:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
}

.tc-insight-icon {
    margin-bottom: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.tc-insight-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--gold);
    line-height: 1.3;
}

.tc-insight-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ===== Growth Badge ===== */
.tc-growth {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.tc-growth-up {
    background: rgba(39, 174, 96, 0.12);
    color: #27AE60;
}

.tc-growth-down {
    background: rgba(231, 76, 60, 0.12);
    color: #E74C3C;
}

.tc-growth-neutral {
    background: rgba(140, 131, 153, 0.12);
    color: var(--text-muted);
}

/* ===== Footer ===== */
.tc-footer {
    text-align: center;
    padding: 30px 20px 10px;
    margin-top: 20px;
    border-top: 1px solid var(--border);
}

.tc-footer p {
    color: var(--text-dim);
    font-size: 0.82rem;
}

.tc-footer a {
    color: var(--gold);
    text-decoration: none;
    transition: var(--transition);
}

.tc-footer a:hover {
    color: var(--gold-light);
}

.tc-back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--gold);
    text-decoration: none;
    font-size: 0.88rem;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 30px;
    margin-bottom: 16px;
    transition: var(--transition);
}

.tc-back-link:hover {
    background: linear-gradient(135deg, rgba(132, 42, 59, 0.2), rgba(197, 126, 143, 0.1));
    border-color: var(--gold-light);
}

/* ===== Loading State ===== */
.tc-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 16px;
}

.tc-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.tc-loading-text {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ===== Disabled State ===== */
.tc-disabled {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
}

.tc-disabled-icon {
    margin-bottom: 16px;
    opacity: 0.5;
    display: flex;
    justify-content: center;
    align-items: center;
}

.tc-disabled h2 {
    color: var(--text-muted);
    font-size: 1.3rem;
    margin-bottom: 8px;
}

.tc-disabled p {
    color: var(--text-dim);
    font-size: 0.9rem;
}

/* ===== Error State ===== */
.tc-error {
    text-align: center;
    padding: 60px 20px;
}

.tc-error-icon {
    margin-bottom: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.tc-error h3 {
    color: var(--danger);
    margin-bottom: 8px;
}

.tc-retry-btn {
    margin-top: 16px;
    padding: 10px 24px;
    border: 1px solid var(--gold);
    border-radius: 30px;
    background: transparent;
    color: var(--gold);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.tc-retry-btn:hover {
    background: var(--gold);
    color: var(--bg-primary);
}

/* ===== Animations ===== */
.tc-fade-in {
    animation: fadeInUp 0.5s ease-out forwards;
    opacity: 0;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tc-stat-card:nth-child(1) { animation-delay: 0.05s; }
.tc-stat-card:nth-child(2) { animation-delay: 0.1s; }
.tc-stat-card:nth-child(3) { animation-delay: 0.15s; }
.tc-stat-card:nth-child(4) { animation-delay: 0.2s; }
.tc-stat-card:nth-child(5) { animation-delay: 0.25s; }
.tc-stat-card:nth-child(6) { animation-delay: 0.3s; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .page-container {
        padding: 16px 12px 40px;
    }

    .tc-header h1 {
        font-size: 1.5rem;
    }

    .tc-header-logo img {
        width: 170px;
    }

    .tc-overview-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .tc-stat-card {
        padding: 16px 12px;
    }

    .tc-stat-value {
        font-size: 1.6rem;
    }

    .tc-charts-row {
        grid-template-columns: 1fr;
    }

    .tc-card {
        padding: 16px;
    }

    .tc-insights-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .tc-ranking-table thead th,
    .tc-ranking-table tbody td {
        padding: 8px 10px;
        font-size: 0.82rem;
    }
}

@media (max-width: 480px) {
    .tc-header-logo img {
        width: 140px;
    }

    .tc-overview-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .tc-stat-value {
        font-size: 1.4rem;
    }

    .tc-stat-label {
        font-size: 0.72rem;
    }

    .tc-insights-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .tc-controls {
        flex-direction: column;
        gap: 8px;
    }
}

/* ===== Print ===== */
@media print {
    body {
        background: #fff;
        color: #333;
    }

    .bg-decoration,
    .tc-controls,
    .tc-back-link,
    .tc-footer {
        display: none !important;
    }

    .tc-card,
    .tc-stat-card,
    .tc-insight-item {
        background: #f9f9f9;
        border-color: #ddd;
        box-shadow: none;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }

    .tc-stat-value,
    .tc-insight-value {
        color: #333;
    }
}

/* ===== SVG Icons Styling ===== */
.tc-icon, .tc-btn-icon, .tc-back-icon {
    width: 20px;
    height: 20px;
    display: inline-block;
    vertical-align: middle;
    stroke: currentColor;
    fill: none;
    transition: var(--transition);
}

.tc-stat-icon .tc-icon {
    width: 32px;
    height: 32px;
    color: var(--gold-light);
}

.tc-stat-card:hover .tc-stat-icon .tc-icon {
    color: var(--gold);
    transform: scale(1.1);
}

.tc-insight-icon .tc-icon {
    width: 28px;
    height: 28px;
    color: var(--gold-light);
}

.tc-insight-item:hover .tc-insight-icon .tc-icon {
    color: var(--gold);
    transform: scale(1.1);
}

.tc-card-title .tc-icon {
    width: 22px;
    height: 22px;
    color: var(--gold-light);
}

.tc-card:hover .tc-card-title .tc-icon {
    color: var(--gold);
    transform: scale(1.05);
}

.tc-btn-icon {
    width: 16px;
    height: 16px;
    stroke-width: 2.2;
}

.tc-back-icon {
    width: 18px;
    height: 18px;
    stroke-width: 2.2;
}

body:not(.ltr) .tc-back-icon {
    transform: rotate(180deg);
}

.tc-back-link:hover .tc-back-icon {
    transform: translateX(-4px);
}

body:not(.ltr) .tc-back-link:hover .tc-back-icon {
    transform: translateX(4px);
}

.tc-disabled-icon .tc-icon {
    width: 48px;
    height: 48px;
    color: var(--text-dim);
}

.tc-error-icon .tc-icon {
    width: 40px;
    height: 40px;
    color: var(--danger);
}
