
:root {
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --accent-color: #0284c7;
    --accent-euro: #10b981; /* Changed from Purple to Emerald Green */
    --border-color: #e2e8f0;
    --table-header: #f1f5f9;
    --footer-bg: #f1f5f9;
    --tech-color: #38bdf8;
    --comm-color: #059669; /* Darker green for Sector branding */
    --cons-color: #fbbf24;
    --text-up:  #4ade80;
    --text-down: #f87171;
}
/* Automatically switch variables if System is set to Dark */
@media (prefers-color-scheme: dark) {
    :root {
      --bg-color: #0f172a;
      --card-bg: #1e293b;
      --text-primary: #f8fafc;
      --text-secondary: #94a3b8;
      --accent-color: #38bdf8;
        --accent-euro: #34d399;
      --border-color: #334155;
      --table-header: rgba(15, 23, 42, 0.5);
      --footer-bg: #1e293b;
        --comm-color: #10b981;
    --text-up:  #00ff88;
    --text-down: #ff4d4d;
    }
}
body {
    /* Layer 1 (Top): The dynamic tint */
    /* Layer 2 (Bottom): The solid theme background variable */
    background: linear-gradient(var(--tint-color, transparent), var(--tint-color, transparent)), 
                var(--bg-color);
    
    /* This ensures the background color fills the screen even when scrolling */
    background-attachment: fixed;
    background-repeat: no-repeat;
    background-size: cover;

    color: var(--text-primary);
    font-family: 'Segoe UI', system-ui, sans-serif;
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    
    /* Smooth transition for the tint change */
    transition: background 0.4s ease-in-out;
}
.container { max-width: 1200px; margin: 0 auto; position: relative; flex: 1; width: 100%; }
header { text-align: center; margin-bottom: 16px; }

.controls-wrapper {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    gap: 15px;
    flex-wrap: wrap;
}

.range-group { display: flex; gap: 5px; }
.range-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
}
.range-btn.active { background: var(--accent-color); color: white; border-color: var(--accent-color); }

select { 
    background-color: var(--card-bg); 
    color: var(--text-primary); 
    border: 1px solid var(--border-color); 
    padding: 8px 12px; 
    border-radius: 8px;
    font-size: 0.9rem;
}

.chart-section {
    background: var(--card-bg);
    padding: 15px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    margin-bottom: 30px;
    height: 380px;
    
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}

.chart-section {
    background: var(--card-bg); padding: 20px;
    border-radius: 16px; border: 1px solid var(--border-color);
    height: 400px; margin-bottom: 30px;
}

.table-container { background: var(--card-bg); border-radius: 16px; border: 1px solid var(--border-color); overflow: hidden; margin-bottom: 40px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 15px; text-align: left; font-size: 0.9rem; }
th { background-color: var(--table-header); color: var(--text-secondary); font-size: 0.7rem; text-transform: uppercase; }

.main-row { cursor: pointer; border-bottom: 1px solid var(--border-color); border-left: 4px solid transparent; }
.main-row:hover { background-color: rgba(255, 255, 255, 0.05); }
.row-tech { border-left-color: var(--tech-color); }
.row-comm { border-left-color: var(--comm-color); }
.row-cons { border-left-color: var(--cons-color); }

.expand-icon { display: inline-block; margin-right: 8px; transition: transform 0.3s; color: var(--accent-color); font-size: 0.7rem; }
.expanded .expand-icon { transform: rotate(90deg); }

.details-row { display: none; background-color: rgba(0, 0, 0, 0.03); border-bottom: 1px solid var(--border-color); }
.details-row.show { display: table-row; }

.details-grid {
    padding: 15px 40px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 20px;
}

.detail-item { display: flex; flex-direction: column; }
.detail-label { font-size: 0.65rem; color: var(--text-secondary); text-transform: uppercase; margin-bottom: 4px; }
.detail-value { font-size: 0.85rem; font-weight: 500; }

.profile-link { color: var(--accent-color); text-decoration: none; font-size: 0.8rem; display: inline-flex; align-items: center; gap: 4px; margin-top: 5px; }

.market-cap-usd { color: var(--accent-color); font-weight: bold; }
.market-cap-eur { color: var(--accent-euro); font-weight: bold; }
.change_1m {
  text-align: right;
  text-wrap: nowrap;
  color: var("--text-secondary");
  font-weight: bold; 
}
.tag { font-size: 0.65rem; color: var(--text-secondary); border: 1px solid var(--border-color); padding: 2px 5px; border-radius: 4px; }

/* PRIORITIZATION LOGIC: Subsector hides first, Cap EUR stays longer */
.mobile-only { display: none; }

@media (max-width: 1200px) { 
    .change_1m_pct { display: none; } 
    .details-grid .change_1m_pct_detail { display: flex; } 
}
@media (max-width: 1100px) { 
    .change_1m { display: none; } 
    .details-grid .change_1m_detail { display: flex; } 
}
@media (max-width: 1000px) { 

    .col-subsector { display: none; } 
    .details-grid .subsector-detail { display: flex; } 
}
@media (max-width: 850px) { 
    .col-rank, .col-country { display: none; } 
    .details-grid .rank-detail, .details-grid .country-detail { display: flex; } 
}
@media (max-width: 700px) { 
    .col-sector { display: none; } 
    .details-grid .sector-detail { display: flex; } 
}
@media (max-width: 550px) { 
    .col-cap-eur { display: none; } 
    .details-grid .eur-detail { display: flex; } 
    .chart-section {
      height: 280px;
    }
}

footer { margin-top: auto; padding: 20px; text-align: center; border-top: 1px solid var(--border-color); color: var(--text-secondary); font-size: 0.8rem; }
.rate-badge { display: inline-flex; align-items: center; gap: 8px; background: var(--footer-bg); padding: 5px 12px; border-radius: 12px; border: 1px solid var(--border-color); margin-top: 10px; }
.pulse { width: 8px; height: 8px; background: #10b981; border-radius: 50%; display: inline-block; animation: pulse-animation 2s infinite; }
@keyframes pulse-animation { 0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); } 70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); } 100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); } }

/* Profile Header */
.profile-header {
    display: flex; align-items: center; gap: 20px;
    margin-bottom: 30px; 
    justify-content: space-between;
  flex-direction: column;
}
.company-logo {
    width: 80px; height: 80px; background: var(--tech-color);
    border-radius: 16px; display: flex; align-items: center;
    justify-content: center; font-size: 2rem; color: white;
}

.top-nav {
    position: sticky;
    top: 0;
    z-index: 1000;
    background-color: var(--bg-color); /* Matches theme */
    padding: 15px 0;
    margin-bottom: 20px;
    border-bottom: 1px solid transparent;
    transition: border-color 0.3s ease;
}

/* Optional: Add a subtle border and shadow only when scrolling */
.top-nav.scrolled {
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(8px); /* Modern frosted glass effect */
    background-color: rgba(var(--bg-rgb), 0.8); 
}

.back-link { 
    text-decoration: none; 
    color: var(--accent-color); 
    font-size: 0.9rem; 
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* Info Grid */
.info-grid {
    display: flex; 
    gap: 20px;
    margin-bottom: 30px;
}
.bio-card, .stats-card {
    background: var(--card-bg); padding: 25px;
    border-radius: 16px; border: 1px solid var(--border-color);
}

.bio-card {
    flex: 2;
}


.stats-card {
    flex: 1;
}


.history-table {
    width: 100%; border-collapse: collapse; background: var(--card-bg);
    border-radius: 16px; overflow: hidden; border: 1px solid var(--border-color);
}
.history-table th, .history-table td { padding: 15px; text-align: left; }
.history-table th { background: var(--table-header); font-size: 0.75rem; text-transform: uppercase; color: var(--text-secondary); }
.history-table tr { border-bottom: 1px solid var(--border-color); }
/* Make table rows feel clickable */
.history-table tbody tr.data-row {
    cursor: pointer;
    transition: background-color 0.2s;
}

.history-table tbody tr.data-row:hover {
    background-color: rgba(56, 189, 248, 0.05);
}

/* The hidden source bar */
.source-info-bar {
    display: none; /* Hidden by default */
    background-color: var(--table-header);
    border-bottom: 1px solid var(--border-color);
}
/* Update the source bar to span the new column count (3 instead of 4) */
.source-info-bar td {
    padding: 0; /* Ensures the inner content controls the spacing */
}

.source-content {
    padding: 15px 25px;
    background-color: var(--table-header);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--accent-color); /* Highlight color for the open bar */
}
.source-info-bar.open {
    display: table-row; /* Shown when toggled */
}
/* Scrollable Container */
.history-scroll-container {
    max-height: 400px; /* Approximately 20 rows of data */
    margin-bottom: 40px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--card-bg);
}

/* Ensure the header stays at the top while scrolling */
.history-table thead th {
    position: sticky;
    top: 0;/* Increase z-index to stay above expanding bars */
    z-index: 20; 
    
    /* Use a solid background variable (no transparency) */
    background-color: var(--card-bg) !important; 
    
    /* Ensure text is distinct */
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.1); /* Subtle shadow for depth */
}

/* Custom Scrollbar for better UI (Optional) */
.history-scroll-container::-webkit-scrollbar {
    width: 8px;
}
.history-scroll-container::-webkit-scrollbar-track {
    background: transparent;
}
.history-scroll-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}
.history-scroll-container::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.source-tag {
    background: var(--accent-color);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    margin-right: 10px;
}
.tag { background: rgba(56, 189, 248, 0.1); color: var(--tech-color); padding: 4px 10px; border-radius: 6px; font-size: 0.8rem; text-wrap:nowrap; }
.col-country { text-wrap:nowrap;}

@media (max-width: 768px) { 
  .info-grid { flex-direction: column; } 
}
a {
    /* KEY FIX: ensures the box only wraps the text */
    display: inline-block; 
    width: fit-content;

    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease, border-bottom 0.2s ease;
    border-bottom: 1px solid transparent;
}

/* Hover state remains the same, but now respects the text width */
a:hover {
    color: var(--tech-color);
    border-bottom: 1px solid var(--tech-color);
}

#stats-label {
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.8rem;
    border-right: 2px solid var(--border-color);
    padding-right: 15px;
}

.green {
  color: var(--text-up) !important;
}
.red {
  color: var(--text-down) !important;
}

/* Container logic */
.controls-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1.25rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}

/* Section 1: The Integrated Filter & Badge */
.filter-group {
    display: flex;
    gap: 8px;
}

.label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.input-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.entity-pill {
    font-size: 0.65rem;
    font-weight: 700;
    background: var(--accent-color);
    color: white;
    padding: 2px 8px;
    border-radius: 6px;
    text-transform: uppercase;
}

#sectorFilter {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    color: var(--text-primary);
    font-weight: 600;
}

/* Section 2: Stats (Stacked on mobile, side-by-side on desktop) */
.stats-main {
    display: flex;
    gap: 1rem;
    padding: 1rem 0;
    border-top: 1px dotted var(--border-color);
    border-bottom: 1px dotted var(--border-color);
}

.stat-item {
    display: flex;
    flex-direction: column;  align-items: center;
}

.stat-label {
    font-size: 0.65rem;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.val {
    font-size: 1.25rem;
    font-weight: 800;
}

.val.usd { color: var(--accent-color); }
.val.eur { color: var(--accent-euro); }
.val.count { color: var(--text-secondary); }

/* Section 3: Time Range */
.range-group {
    display: flex;
    background: var(--table-header);
    padding: 4px;
    border-radius: 10px;
}

.range-btn {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
}

.range-btn.active {
    background: var(--card-bg);
    color: var(--accent-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.range-section{
  display: flex;
  flex-direction: row;
  gap: 8px;
}
.filter-group {
  flex-direction: row;
}
  
/* Desktop Polish (Tablets and Up) */
@media (min-width: 768px) {
    .controls-wrapper {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 1rem 2rem;
    }
  .profile-header {
  flex-direction: row;
  }
    .filter-group { width: 250px; 
  flex-direction: column;}
    
.range-section{
  flex-direction: column;
}
    .stats-main {
        display: flex;
        gap: 3rem;
        border: none;
        padding: 0;
    }

    .val { font-size: 1.6rem; }

    .range-group { width: 220px; }
}

.title {
  align-items: center;
  display: flex;
  justify-content: center; gap:5px;
}

.profile-title {
  display: flex;
  align-items: center;
  gap: 20px;
}

.stats-main.profile {

      background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.05);    padding: 1rem 2rem;
}
