/* CSS Variables for theming */
:root {
    --bg-primary: #fff;
    --bg-secondary: #f5f5f5;
    --bg-tertiary: #f0f0f0;
    --bg-hover: #f9f9f9;
    --text-primary: #333;
    --text-secondary: #555;
    --text-tertiary: #666;
    --text-muted: #999;
    --border-color: #eee;
    --border-strong: #ddd;
    --border-header: #333;
    --accent-bg: #333;
    --accent-text: #fff;
    --icon-bg: #f5f5f5;
    --icon-text: #666;
}

[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #252525;
    --bg-tertiary: #303030;
    --bg-hover: #2a2a2a;
    --text-primary: #e0e0e0;
    --text-secondary: #c0c0c0;
    --text-tertiary: #a0a0a0;
    --text-muted: #707070;
    --border-color: #333;
    --border-strong: #444;
    --border-header: #e0e0e0;
    --accent-bg: #e0e0e0;
    --accent-text: #1a1a1a;
    --icon-bg: #303030;
    --icon-text: #a0a0a0;
}

/* Base styles */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body { 
    color: var(--text-primary); 
    background-color: var(--bg-primary); 
    min-height: 100%; 
    margin: 0; 
    font-family: Roboto, sans-serif; 
    font-size: 14px; 
    line-height: 20px; 
    font-weight: 300;
    transition: background-color 0.3s, color 0.3s;
}
img { vertical-align: middle; max-width: 100%; display: inline-block; border: 0; }
a { color: var(--text-primary); text-decoration: none; background-color: transparent; }
a:hover { opacity: 0.7; }
h1, h2, h3, h4, h5, h6 { font-family: Montserrat, sans-serif; font-weight: 400; }
button { overflow: visible; text-transform: none; cursor: pointer; }
input { line-height: normal; }

/* Navigation */
.navigation-bar { padding: 20px 0; border-bottom: 1px solid var(--border-color); background: var(--bg-primary); }
.w-container { max-width: 1600px; margin: 0 auto; padding: 0 40px; }
.nav-inner { display: flex; justify-content: space-between; align-items: center; }
.brand-text { font-family: Montserrat, sans-serif; font-size: 18px; font-weight: 400; letter-spacing: 1px; }
.navigation-menu { display: flex; gap: 30px; align-items: center; }
.navigation-link { font-family: Montserrat, sans-serif; font-size: 14px; font-weight: 400; text-transform: uppercase; letter-spacing: 1px; padding: 5px 0; border-bottom: 1px solid transparent; }
.navigation-link:hover, .navigation-link.w--current { border-bottom: 1px solid var(--text-primary); }

/* Theme toggle */
.theme-toggle { 
    position: fixed;
    top: 0;
    right: 0;
    width: 48px;
    height: 48px;
    background: #333;
    border-radius: 0 0 0 48px;
    cursor: pointer;
    z-index: 9999;
    transition: background 0.3s;
}
[data-theme="dark"] .theme-toggle { background: #e0e0e0; }
.theme-toggle:hover { opacity: 0.8; }

/* Page header */
.section { padding: 40px 0; }
.page-header { margin-bottom: 40px; }
.page-title { font-size: 32px; font-weight: 300; margin-bottom: 24px; }
.page-intro { font-size: 15px; color: var(--text-secondary); line-height: 1.8; }
.page-intro p { margin-bottom: 16px; }

/* Language switcher */
.lang-switcher { display: flex; gap: 8px; margin-bottom: 24px; align-items: center; }
.lang-btn { 
    font-family: Montserrat, sans-serif; 
    font-size: 11px; 
    font-weight: 500; 
    padding: 6px 12px; 
    border: 1px solid var(--border-strong); 
    background: var(--bg-primary); 
    color: var(--text-tertiary);
    cursor: pointer; 
    text-transform: uppercase; 
    letter-spacing: 1px; 
    transition: all 0.2s; 
}
.lang-btn:hover { border-color: var(--text-primary); }
.lang-btn.active { background: var(--accent-bg); color: var(--accent-text); border-color: var(--accent-bg); }
.lang-content { display: none; }
.lang-content.active { display: block; }

/* Filters */
.filters-section { margin-bottom: 40px; padding-bottom: 30px; border-bottom: 1px solid var(--border-color); }
.filter-group { margin-bottom: 20px; }
.filter-label { font-family: Montserrat, sans-serif; font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 10px; display: block; }
.filter-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-btn { 
    font-family: Montserrat, sans-serif; 
    font-size: 12px; 
    font-weight: 400; 
    padding: 8px 16px; 
    border: 1px solid var(--border-strong); 
    background: var(--bg-primary); 
    color: var(--text-tertiary);
    cursor: pointer; 
    transition: all 0.2s; 
}
.filter-btn:hover { border-color: var(--text-primary); }
.filter-btn.active { background: var(--accent-bg); color: var(--accent-text); border-color: var(--accent-bg); }
.filter-btn .count { font-size: 10px; opacity: 0.7; margin-left: 5px; }
.search-container { margin-bottom: 20px; }
.search-input { 
    font-family: Roboto, sans-serif; 
    font-size: 14px; 
    padding: 12px 16px; 
    border: 1px solid var(--border-strong); 
    background: var(--bg-primary);
    color: var(--text-primary);
    width: 100%; 
    max-width: 400px; 
    outline: none; 
}
.search-input:focus { border-color: var(--text-primary); }
.search-input::placeholder { color: var(--text-muted); }

/* Stats bar */
.stats-bar { 
    display: flex; 
    gap: 30px; 
    font-size: 13px; 
    color: var(--text-tertiary); 
    margin-bottom: 30px; 
    flex-wrap: wrap; 
    padding: 16px 0; 
    border-top: 1px solid var(--border-color); 
    border-bottom: 1px solid var(--border-color); 
}
.stat-item span { font-family: Montserrat, sans-serif; font-weight: 500; color: var(--text-primary); }
.source-stats { display: flex; gap: 15px; margin-left: auto; }
.source-stat { font-size: 11px; padding: 4px 8px; background: var(--bg-secondary); color: var(--text-muted); font-family: Montserrat, sans-serif; }
.source-stat.active { background: var(--bg-tertiary); color: var(--text-primary); }

/* Table */
.table-header { 
    display: grid; 
    grid-template-columns: 60px 70px 60px 1fr 120px 120px; 
    gap: 16px; 
    padding: 12px 0; 
    border-bottom: 2px solid var(--border-header); 
    font-family: Montserrat, sans-serif; 
    font-size: 11px; 
    font-weight: 500; 
    text-transform: uppercase; 
    letter-spacing: 1px; 
    color: var(--text-muted); 
}
.table-header .col-prazo, .table-header .col-valor { text-align: right; }
.competition-row { 
    display: grid; 
    grid-template-columns: 60px 70px 60px 1fr 120px 120px; 
    gap: 16px; 
    padding: 16px 0; 
    border-bottom: 1px solid var(--border-color); 
    align-items: center; 
    transition: background 0.2s; 
}
.competition-row:hover { background: var(--bg-hover); }

/* GLM relevance badge next to the title. Green = strong (70+),
   amber = maybe (35-69). Gated rows are hidden by the filter, not styled. */
.score-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 0 5px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    vertical-align: middle;
    background: rgba(181, 137, 0, .16);
    color: #b58900;
}
.score-strong .score-badge { background: rgba(26, 127, 55, .16); color: #1a7f37; }

.competition-row.hidden { display: none; }

/* Table cells */
.type-icon { 
    width: 40px; 
    height: 40px; 
    display: inline-flex; 
    align-items: center; 
    justify-content: center; 
    font-family: Montserrat, sans-serif; 
    font-size: 9px; 
    font-weight: 600; 
    text-transform: uppercase; 
    background: var(--icon-bg); 
    color: var(--icon-text); 
}
.type-icon.contest { background: var(--accent-bg); color: var(--accent-text); }
.cell-country { font-family: Montserrat, sans-serif; font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: 1px; color: var(--text-tertiary); }
.cell-source { font-family: Montserrat, sans-serif; font-size: 9px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; padding: 4px 6px; background: var(--bg-tertiary); color: var(--text-tertiary); display: inline-block; }
.cell-title { display: block; }
.cell-title a { font-family: Montserrat, sans-serif; font-size: 14px; font-weight: 500; line-height: 1.4; color: var(--text-primary); display: block; }
.cell-authority { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.cell-deadline { font-family: Montserrat, sans-serif; font-size: 12px; font-weight: 500; text-align: right; color: var(--text-tertiary); }
.cell-deadline.urgent { color: var(--text-primary); font-weight: 600; }
.cell-deadline.soon { color: var(--text-secondary); }
.cell-value { font-family: Montserrat, sans-serif; font-size: 12px; color: var(--text-tertiary); text-align: right; }
.loading, .empty-state { text-align: center; padding: 60px 20px; color: var(--text-tertiary); grid-column: 1 / -1; }

/* Footer */
.footer { padding: 40px 0; border-top: 1px solid var(--border-color); margin-top: 60px; }
.footer-content { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 40px; }
.footer-links { display: flex; gap: 20px; align-items: center; }
.footer-links img { height: 30px; opacity: 0.6; transition: opacity 0.2s; }
[data-theme="dark"] .footer-links img { filter: invert(1); }
.footer-links img:hover { opacity: 1; }
.footer-info { max-width: 500px; }
.footer-info h4 { font-family: Montserrat, sans-serif; font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 10px; }
.footer-info p { font-size: 13px; color: var(--text-tertiary); margin-bottom: 8px; }
.footer-info a { color: var(--text-primary); text-decoration: underline; }
.data-sources { display: flex; gap: 12px; margin-top: 15px; flex-wrap: wrap; }
.data-source { font-family: Montserrat, sans-serif; font-size: 11px; font-weight: 500; padding: 6px 12px; background: var(--bg-secondary); color: var(--text-tertiary); }
.data-source.active { background: var(--accent-bg); color: var(--accent-text); }
.data-source-link { display: block; font-size: 10px; color: var(--text-muted); margin-top: 2px; }
[data-theme="dark"] .data-source.active .data-source-link { color: var(--text-muted); }

/* Responsive */
@media (max-width: 768px) {
    .navigation-menu { display: none; }
    .w-container { padding: 0 20px; }
    .filter-buttons { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 10px; }
    .filter-btn { white-space: nowrap; }
    .table-header, .competition-row { grid-template-columns: 40px 40px 45px 1fr 70px 70px; gap: 8px; font-size: 10px; }
    .source-stats { margin-left: 0; margin-top: 10px; width: 100%; }
    .footer-content { flex-direction: column; }
    .lang-switcher { justify-content: flex-start; }
    .theme-toggle { width: 36px; height: 36px; }
}

/* Phones: the 6-column grid cannot fit — switch rows to cards */
@media (max-width: 640px) {
    .w-container { padding: 0 14px; }
    .page-title { font-size: 22px; line-height: 1.3; }
    .page-intro { font-size: 14px; }
    .search-input { max-width: 100%; }
    .stats-bar { gap: 10px; }
    .source-stats { gap: 6px; flex-wrap: wrap; }
    .table-header { display: none; }
    .competition-row {
        display: flex;
        flex-wrap: wrap;
        gap: 6px 12px;
        padding: 14px 0;
        align-items: center;
    }
    .competition-row.hidden { display: none; }
    .competition-row > .cell-title { flex: 1 1 100%; order: -1; }
    .cell-title a { font-size: 14px; }
    .type-icon { width: 28px; height: 28px; font-size: 8px; }
    .cell-deadline, .cell-value { text-align: left; }
    .cell-deadline { padding: 2px 6px; background: var(--bg-secondary); }
}
