/* ============================================================
   COST Action CA19130 - Fintech and AI in Finance
   Shared Stylesheet
   ============================================================ */

/* --- 1. Custom Properties --- */
:root {
    --cost-purple: #5B2D8A;
    --cost-blue: #2B5F9E;
    --cost-teal: #00A0B0;
    --cost-orange: #E87722;
    --cost-green: #7AB800;
    --dark: #1a1a2e;
    --light: #f8f9fa;
    --gray: #6c757d;
    --border: #dee2e6;
    --topbar-height: 32px;
    --sidebar-width: 180px;
}

/* --- 2. Reset & Base Typography --- */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--dark);
    background: var(--light);
}

a { color: var(--cost-blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
h1, h2, h3, h4, h5, h6 { line-height: 1.25; }

/* --- 3. Topbar --- */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-height);
    background: linear-gradient(135deg, var(--cost-purple), var(--cost-blue));
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.75rem;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12);
}

.topbar-logo {
    display: flex;
    align-items: center;
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    text-decoration: none;
}

.topbar-logo:hover { text-decoration: none; color: white; }
.topbar-logo .action-id { color: var(--cost-orange); margin-left: 0.25rem; }

.topbar-logo .badge {
    font-size: 0.5rem;
    background: rgba(255, 255, 255, 0.2);
    padding: 0.1rem 0.35rem;
    border-radius: 2px;
    margin-left: 0.5rem;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0.35rem;
    flex-direction: column;
    gap: 3px;
}

.hamburger span {
    display: block;
    width: 18px; height: 2px;
    background: white;
    border-radius: 1px;
}

/* --- 4. Sidebar --- */
.sidebar {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--topbar-height));
    background: #0f172a;
    z-index: 999;
    overflow-y: auto;
    font-size: 0.75rem;
}

.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }

.sidebar-home {
    display: block;
    padding: 0.5rem 0.75rem;
    color: white;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.75rem;
    border-bottom: 1px solid #1e293b;
}

.sidebar-home:hover { background: #1e293b; text-decoration: none; color: white; }

.sidebar-home.active {
    background: linear-gradient(90deg, var(--cost-purple), transparent);
    border-left: 2px solid var(--cost-orange);
}

.sidebar-section { border-bottom: 1px solid #1e293b; }

.sidebar-section-header {
    padding: 0.5rem 0.75rem;
    color: #94a3b8;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.15s, color 0.15s;
}

.sidebar-section-header:hover { background: #1e293b; color: white; }
.sidebar-section.active .sidebar-section-header { color: var(--cost-orange); background: #1e293b; }
.sidebar-section-header .toggle { font-size: 0.5rem; transition: transform 0.2s; }
.sidebar-section.active .sidebar-section-header .toggle { transform: rotate(180deg); }
.sidebar-links { display: none; padding: 0 0 0.25rem 0; }
.sidebar-section.active .sidebar-links { display: block; }

.sidebar-link {
    display: block;
    padding: 0.25rem 0.5rem 0.25rem 0.9rem;
    color: #64748b;
    text-decoration: none;
    font-size: 0.7rem;
    border-left: 3px solid transparent;
    transition: color 0.15s, background 0.15s;
}

.sidebar-link:hover { color: white; background: rgba(255, 255, 255, 0.05); text-decoration: none; }

.sidebar-link.active {
    color: var(--cost-orange);
    border-left-color: var(--section-color, var(--cost-orange));
    background: rgba(255, 255, 255, 0.05);
}

/* --- 5. Content Area --- */
.content {
    margin-left: var(--sidebar-width);
    margin-top: var(--topbar-height);
    min-height: calc(100vh - var(--topbar-height));
}

.content-inner { padding: 2rem; max-width: 1400px; margin: 0 auto; }

/* --- 6. Mobile Overlay --- */
.mobile-overlay {
    position: fixed;
    inset: 0;
    background: #0f172a;
    z-index: 1001;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    padding-top: var(--topbar-height);
}

.mobile-overlay.open { transform: translateX(0); }
.mobile-overlay-section { border-bottom: 1px solid #1e293b; }

.mobile-overlay-header {
    padding: 1rem 1.25rem;
    color: #94a3b8;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mobile-overlay-header .toggle-icon { font-size: 0.7rem; transition: transform 0.2s; }
.mobile-overlay-section.expanded .toggle-icon { transform: rotate(180deg); }
.mobile-overlay-links { display: none; padding: 0 1.25rem 0.75rem; }
.mobile-overlay-section.expanded .mobile-overlay-links { display: block; }

.mobile-overlay-links a {
    display: block;
    padding: 0.5rem 0 0.5rem 0.75rem;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.9rem;
    border-left: 3px solid transparent;
}

.mobile-overlay-links a:hover { color: white; text-decoration: none; }
.mobile-overlay-links a.active { color: var(--cost-orange); border-left-color: var(--cost-orange); }

/* --- 7. Hero Variants --- */
.compact-hero,
.full-hero {
    background: linear-gradient(135deg, var(--cost-purple) 0%, var(--cost-blue) 50%, var(--cost-teal) 100%);
    color: white;
    padding: 2rem;
    text-align: center;
}

.full-hero { padding: 3rem 2rem; }

.compact-hero h1, .full-hero h1 { font-size: 1.75rem; font-weight: 700; margin-bottom: 0.25rem; }
.compact-hero .subtitle, .full-hero .subtitle { font-size: 1rem; opacity: 0.9; }
.compact-hero .action-id, .full-hero .action-id { font-size: 0.85rem; color: var(--cost-orange); font-weight: 600; margin-bottom: 0.5rem; }
.compact-hero .period, .full-hero .period { font-size: 0.85rem; opacity: 0.8; }

.compact-hero .hero-logos,
.full-hero .hero-logos {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.compact-hero .hero-logos img, .full-hero .hero-logos img { height: 45px; width: auto; }

.compact-hero .hero-logos .eu-logo,
.full-hero .hero-logos .eu-logo { background: white; padding: 4px 8px; border-radius: 4px; }

/* --- 8. Cards, Grids, Stat Boxes --- */
.card {
    background: white;
    border-radius: 10px;
    padding: 1.25rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12); }

.stat-card {
    text-align: center;
    background: white;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.stat-card .stat-number { font-size: 2rem; font-weight: 700; color: var(--cost-purple); }
.stat-card .stat-label { font-size: 0.8rem; color: var(--gray); text-transform: uppercase; letter-spacing: 0.05em; }

.stats-banner {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
    padding: 1.25rem;
    background: white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.grid-2, .grid-3, .grid-4 { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.cta-card { border-top: 4px solid var(--cost-purple); text-align: center; }
.cta-card a { display: inline-block; margin-top: 0.75rem; font-weight: 500; font-size: 0.85rem; }

/* --- 9. Tables --- */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; background: white; }

.data-table th {
    background: var(--light);
    color: var(--dark);
    font-weight: 600;
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 2px solid var(--border);
}

.data-table td { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); }
.data-table tbody tr:hover { background: rgba(91, 45, 138, 0.04); }

/* --- 10. Chart Containers --- */
.chart-container {
    background: white;
    border-radius: 10px;
    padding: 1.25rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.chart-container h3 { font-size: 0.95rem; color: var(--dark); margin-bottom: 0.75rem; text-align: center; }
.chart-wrapper { height: 200px; position: relative; }

/* --- 11. Footer --- */
.footer { background: #1a1a2e; color: white; padding: 2rem; }
.footer-content { max-width: 1200px; margin: 0 auto; }
.footer-title h3 { font-size: 1rem; margin-bottom: 0.25rem; }
.footer-title .completed { font-size: 0.8rem; color: rgba(255, 255, 255, 0.6); }

.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin: 1.5rem 0;
}

.footer-col h4 {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.footer-col a { display: block; color: rgba(255, 255, 255, 0.7); text-decoration: none; font-size: 0.85rem; padding: 0.15rem 0; }
.footer-col a:hover { color: var(--cost-orange); text-decoration: none; }

.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 1.5rem;
    padding-top: 1rem;
    text-align: center;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.4);
}

.footer-bottom a { color: var(--cost-orange); }

/* --- 12. Responsive --- */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
    .sidebar.open { transform: translateX(0); }
    .content { margin-left: 0; }
    .hamburger { display: flex; }
    .compact-hero h1, .full-hero h1 { font-size: 1.4rem; }
    .stats-banner { gap: 1rem; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .chart-wrapper { height: 180px; }
}

@media (max-width: 768px) {
    .page-hero h1 { font-size: 1.5rem; }
    .page-hero .subtitle { font-size: 0.95rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .page-filters { flex-direction: column; }
    .page-filters input[type="text"], .page-filters select { width: 100%; }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
    .compact-hero h1, .full-hero h1 { font-size: 1.2rem; }
    .compact-hero .subtitle, .full-hero .subtitle { font-size: 0.85rem; }
    .data-table { font-size: 0.75rem; }
    .data-table th, .data-table td { padding: 0.4rem 0.5rem; }
    .content-inner { padding: 1rem; }
    .footer-grid { grid-template-columns: 1fr; }
}

/* --- 13. Print Styles --- */
@media print {
    .topbar, .sidebar, .mobile-overlay, .hamburger, .footer { display: none; }
    .content { margin-left: 0; margin-top: 0; }
    .content-inner { max-width: 100%; padding: 0; }
    a[href]::after { content: " (" attr(href) ")"; font-size: 0.8em; color: var(--gray); }
    .chart-container, .chart-wrapper { break-inside: avoid; }
}

/* --- 14. Accessibility --- */
.skip-to-content {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 9999;
    background: var(--cost-purple);
    color: white;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.skip-to-content:focus {
    left: 0;
    outline: 2px solid var(--cost-orange);
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms;
        animation-iteration-count: 1;
        transition-duration: 0.01ms;
    }
}

/* --- 15. Chart Height Variants --- */
.chart-wrapper--sm { height: 180px; position: relative; }
.chart-wrapper--md { height: 280px; position: relative; }
.chart-wrapper--lg { height: 350px; position: relative; }

/* --- Utility Classes --- */

/* Breadcrumb */
.breadcrumb { font-size: 0.8rem; color: var(--gray); padding: 0.75rem 0; margin-bottom: 1rem; }
.breadcrumb a { color: var(--cost-blue); }
.breadcrumb span { color: var(--dark); }

/* Section Title */
.section-title { font-size: 1.5rem; color: var(--cost-purple); margin-bottom: 1rem; }

.section-title::after {
    content: '';
    display: block;
    width: 60px; height: 3px;
    background: var(--cost-orange);
    margin-top: 0.5rem;
}

/* Badges */
.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 20px; font-size: 0.75rem; font-weight: 500; }
.badge-purple { background: rgba(91, 45, 138, 0.1); color: var(--cost-purple); }
.badge-orange { background: rgba(232, 119, 34, 0.1); color: var(--cost-orange); }
.badge-teal { background: rgba(0, 160, 176, 0.1); color: var(--cost-teal); }

/* Country Pills */
.country-pill {
    display: inline-block;
    background: white;
    border: 1px solid var(--border);
    padding: 0.2rem 0.5rem;
    border-radius: 20px;
    font-size: 0.75rem;
    margin: 0.15rem;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.country-pill:hover { background: var(--cost-purple); color: white; border-color: var(--cost-purple); }
.country-pill.itc { border-color: var(--cost-orange); background: rgba(232, 119, 34, 0.1); }

/* Working Group Cards */
.wg-card { border-left: 4px solid var(--cost-teal); }
.wg-card.wg1 { border-left-color: var(--cost-purple); }
.wg-card.wg2 { border-left-color: var(--cost-blue); }
.wg-card.wg3 { border-left-color: var(--cost-green); }

/* Search */
.search-box {
    width: 100%;
    padding: 0.6rem 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    margin-bottom: 1rem;
}

.search-box:focus { outline: none; border-color: var(--cost-purple); box-shadow: 0 0 0 2px rgba(91, 45, 138, 0.2); }

/* Filters */
.filter-bar { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }

.filter-btn {
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: white;
    cursor: pointer;
    font-size: 0.8rem;
    font-family: inherit;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.filter-btn:hover,
.filter-btn.active { background: var(--cost-purple); color: white; border-color: var(--cost-purple); }

/* Tags */
.tag { display: inline-block; padding: 0.1rem 0.4rem; border-radius: 3px; font-size: 0.7rem; background: var(--light); }

/* --- 16. Page Hero Variants --- */
.page-hero { color: white; padding: 2rem 2rem 1.5rem; text-align: center; }
.page-hero h1 { font-size: 2rem; font-weight: 700; margin-bottom: 0.5rem; }
.page-hero .subtitle { font-size: 1.1rem; opacity: 0.95; max-width: 700px; margin: 0 auto; font-weight: 300; }
.page-hero p { opacity: 0.9; }
.page-hero .hero-badge { display: inline-block; background: rgba(255,255,255,0.2); padding: 0.3rem 1rem; border-radius: 15px; font-size: 0.85rem; margin-bottom: 1rem; }
.page-hero .period { font-size: 1rem; opacity: 0.8; }
.page-hero .flag { font-size: 3rem; margin-bottom: 0.5rem; }
.page-hero .stats-row { display: flex; justify-content: center; gap: 3rem; margin-top: 1.25rem; flex-wrap: wrap; }
.page-hero .stat-item { text-align: center; }
.page-hero .stat-number { font-size: 2rem; font-weight: 700; }
.page-hero .stat-label { font-size: 0.8rem; opacity: 0.8; text-transform: uppercase; letter-spacing: 0.05em; }
.page-hero .nav-pills { display: flex; justify-content: center; gap: 0.5rem; margin-top: 1.5rem; flex-wrap: wrap; }
.page-hero .nav-pills a { padding: 0.4rem 1rem; border-radius: 20px; font-size: 0.8rem; text-decoration: none; background: rgba(255,255,255,0.2); color: white; }
.page-hero .nav-pills a:hover { background: rgba(255,255,255,0.3); text-decoration: none; }
.page-hero .nav-pills a.active { background: white; color: var(--cost-purple); }

.page-hero--default { background: linear-gradient(135deg, var(--cost-purple) 0%, var(--cost-blue) 50%, var(--cost-teal) 100%); }
.page-hero--blue { background: linear-gradient(135deg, var(--cost-blue), var(--cost-teal)); }
.page-hero--green { background: linear-gradient(135deg, var(--cost-green) 0%, var(--cost-teal) 100%); }
.page-hero--purple { background: linear-gradient(135deg, var(--cost-purple), #3d1a6e); }
.page-hero--dark { background: linear-gradient(135deg, #2d1b4e 0%, var(--cost-purple) 100%); }
.page-hero--financial { background: linear-gradient(135deg, #5B2D8A 0%, #3a1a60 100%); }
.page-hero--report { background: linear-gradient(135deg, var(--cost-green) 0%, var(--cost-teal) 50%, var(--cost-blue) 100%); }

/* --- 17. Page Containers --- */
.page-container { max-width: 1400px; margin: 0 auto; padding: 1.5rem 2rem; }
.page-container--narrow { max-width: 1200px; margin: 0 auto; padding: 1.5rem 2rem; }
.page-container--compact { max-width: 1000px; margin: 0 auto; padding: 1.5rem 2rem; }
.page-container--tight { max-width: 900px; margin: 0 auto; padding: 2rem; }

/* --- 18. Page Breadcrumb --- */
.page-breadcrumb { background: white; padding: 0.75rem 2rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.page-breadcrumb a { color: var(--cost-purple); text-decoration: none; }
.page-breadcrumb a:hover { text-decoration: underline; }
.page-breadcrumb span { color: var(--gray); }

/* --- 19. Section Heading with underline --- */
.section-heading { font-size: 1.5rem; color: var(--cost-purple); margin: 0.75rem 0 0.5rem; }
.section-heading::after { content: ''; display: block; width: 50px; height: 3px; background: var(--cost-orange); margin-top: 0.5rem; }

/* --- 20. Stats Grid --- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 1rem; margin: 1rem 0; }
.stat-box { background: var(--light); border-radius: 8px; padding: 1rem; text-align: center; }
.stat-box .value { font-size: 1.5rem; font-weight: 700; color: var(--cost-blue); }
.stat-box .label { font-size: 0.75rem; color: var(--gray); }

/* --- 21. Highlight Boxes --- */
.highlight-box { background: linear-gradient(135deg, rgba(91,45,138,0.08), rgba(43,95,158,0.08)); border-left: 4px solid var(--cost-purple); padding: 1rem; border-radius: 0 12px 12px 0; margin: 1.5rem 0; }
.highlight-box--orange { background: rgba(232, 119, 34, 0.1); border-left-color: var(--cost-orange); }

/* --- 22. Content Cards --- */
.content-card { background: white; border-radius: 12px; padding: 2rem; box-shadow: 0 4px 20px rgba(0,0,0,0.08); margin-bottom: 1.5rem; }
.content-card h2 { color: var(--cost-purple); margin-bottom: 1rem; font-size: 1.3rem; }

/* --- 23. Page Filters --- */
.page-filters { background: white; padding: 1rem; border-radius: 10px; box-shadow: 0 4px 20px rgba(0,0,0,0.08); margin-bottom: 1rem; display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; }
.page-filters input[type="text"] { flex: 1; min-width: 200px; padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: 6px; font-size: 0.9rem; font-family: inherit; }
.page-filters select { padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: 6px; font-size: 0.9rem; font-family: inherit; background: white; min-width: 150px; }
.page-filters input:focus, .page-filters select:focus { outline: none; border-color: var(--cost-purple); box-shadow: 0 0 0 2px rgba(91, 45, 138, 0.2); }

/* --- 24. Nav Buttons --- */
.nav-buttons { display: flex; justify-content: space-between; margin-top: 0.75rem; padding-top: 2rem; border-top: 1px solid #eee; }
.nav-btn { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--cost-purple); text-decoration: none; font-weight: 500; font-size: 0.9rem; }
.nav-btn:hover { color: var(--cost-teal); text-decoration: none; }
