/* MESTO 2026 - KESKITETTY TYYLITIEDOSTO */

:root {
    --primary: #4E82A5;     /* Turnauksen pääväri (Sininen) */
    --bg: #F1F5F9;          /* Sivuston taustaväri */
    --text: #0F172A;        /* Päätekstin väri */
    --muted: #64748B;       /* Aputekstien väri */
    --border: #CBD5E1;      /* Reunaviivojen väri */
    --white: #FFFFFF;       /* Valkoinen tausta */
}

/* --- PERUSASETUKSET --- */
html {
    overflow-y: scroll; /* Estää sivun hyppimisen datan latautuessa */
}

body { 
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg); 
    color: var(--text); 
    margin: 0; 
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main { 
    flex: 1; 
}

.container { 
    max-width: 1200px; 
    margin: 0 auto; 
    padding: 12px; 
    width: 100%;
    box-sizing: border-box; 
}

/* --- YLÄTUNNISTE (HEADER) --- */
.site-header {
    background-color: var(--primary);
    color: var(--white);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100; /* Korkea arvo jotta pysyy muiden päällä */
}

.header-title {
    font-weight: 800;
    font-size: 20px;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin: 0;
    flex: 2;
    text-align: center;
}

.header-spacer, .header-actions { 
    flex: 1; 
}

.header-actions { 
    display: flex; 
    justify-content: flex-end; 
}

.menu-btn {
    background: none;
    border: none;
    color: var(--white);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
}

/* --- SIVUSTA LIUKUVA VALIKKO --- */
.menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
    z-index: 110;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.menu-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.side-menu {
    position: fixed;
    top: 0; 
    right: -300px;
    width: 280px; 
    height: 100%;
    background-color: #1E293B;
    color: var(--white);
    z-index: 120;
    box-shadow: -5px 0 25px rgba(0,0,0,0.3);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.side-menu.open { 
    right: 0; 
}

.side-menu-header {
    padding: 20px;
    display: flex;
    justify-content: flex-end;
}

.close-btn {
    background: none; 
    border: none; 
    color: #94A3B8; 
    cursor: pointer;
}

.menu-links {
    list-style: none; 
    padding: 10px 20px; 
    margin: 0;
}

.menu-links li a {
    display: block;
    color: #E2E8F0;
    text-decoration: none;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 12px;
    border-bottom: 1px solid #334155;
    transition: color 0.2s;
}

.menu-links li a:hover {
    color: #38BDF8;
}

/* --- ALATUNNISTE (FOOTER) --- */
.site-footer {
    background-color: var(--primary);
    color: var(--white);
    padding: 24px 20px;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    margin-top: 40px;
    width: 100%;
    box-sizing: border-box;
    display: block !important; /* Varmistetaan näkyvyys */
}

/* --- TYÖKALUPALKKI (TOOLBAR) --- */
.toolbar { 
    background: var(--white); 
    padding: 12px; 
    border-radius: 12px; 
    box-shadow: 0 1px 3px rgba(0,0,0,0.1); 
    border: 1px solid var(--border);
    display: flex; 
    flex-direction: column;
    gap: 12px; 
    align-items: center; 
    margin: 20px 0;
}

@media (min-width: 640px) {
    .toolbar {
        flex-direction: row;
        justify-content: space-between;
    }
}

.search-wrapper { 
    width: 100%;
}

@media (min-width: 640px) {
    .search-wrapper {
        flex: 1;
    }
}

.search-input { 
    width: 100%; 
    padding: 10px 16px; 
    border-radius: 8px; 
    border: 1px solid var(--border);
    background: #F8FAFC; 
    outline: none; 
    font-weight: 600;
    box-sizing: border-box;
}

.search-input:focus { 
    border-color: var(--primary); 
    box-shadow: 0 0 0 2px rgba(78, 130, 165, 0.2); 
}

.btn-group { display: flex; background: #F1F5F9; padding: 4px; border-radius: 8px; gap: 4px; }
.btn-view { 
    padding: 8px; border: none; background: transparent; cursor: pointer; border-radius: 6px; color: var(--muted);
}
.btn-view.active { background: var(--primary); color: var(--white); }

.btn-print {
    padding: 10px 15px; background: var(--white); border: 1px solid var(--border); border-radius: 8px;
    color: var(--muted); cursor: pointer; font-weight: 700; font-size: 11px; text-transform: uppercase;
    display: flex; align-items: center; gap: 5px; white-space: nowrap;
}

/* --- TAULUKOT JA KORTIT --- */
.section-header { border-left: 6px solid var(--primary); padding-left: 15px; margin: 30px 0 15px 0; }
.section-title { font-size: 22px; font-weight: 900; color: var(--primary); margin: 0; text-transform: uppercase; }

.grid-layout { display: grid; grid-template-columns: 1fr; gap: 20px; }
@media (min-width: 1024px) { 
    .grid-layout { grid-template-columns: 7fr 5fr; } 
}

.card { background: var(--white); border-radius: 12px; border: 1px solid var(--border); overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.card-header { background: var(--primary); color: var(--white); padding: 10px 15px; font-weight: 800; text-transform: uppercase; font-size: 12px; }

.standings-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.standings-table th { background: #F8FAFC; color: var(--muted); padding: 8px 4px; text-align: center; border-bottom: 1px solid var(--border); font-weight: 900; text-transform: uppercase; font-size: 9px; }
.standings-table td { padding: 10px 4px; border-bottom: 1px solid #F1F5F9; text-align: center; }
.standings-table .team-cell { text-align: left; font-weight: 800; color: var(--text); padding-left: 12px; width: 40%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.standings-table tr:hover { background-color: #F8FAFC; cursor: pointer; }

.font-black { font-weight: 900; color: var(--text); }

/* --- TAULUKKONÄKYMÄ (LISTAT) --- */
.list-container { background: var(--white); border-radius: 12px; border: 1px solid var(--border); overflow: hidden; }
.list-row { display: flex; align-items: center; padding: 12px; border-bottom: 1px solid #F1F5F9; gap: 8px; }
.list-row:last-child { border-bottom: none; }

.list-datetime { width: 65px; flex-shrink: 0; line-height: 1.2; }
.list-date { font-size: 8px; font-weight: 700; color: var(--muted); }
.list-time { font-size: 12px; font-weight: 700; color: var(--text); }

.list-id { width: 30px; flex-shrink: 0; font-size: 10px; color: var(--muted); text-align: center; font-weight: 600; }
.list-field { width: 30px; flex-shrink: 0; font-size: 10px; font-weight: 800; text-align: center; background: #F1F5F9; border-radius: 4px; padding: 2px 0; }

.list-team-home { flex: 1; text-align: center; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-team-away { flex: 1; text-align: center; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.list-score { width: 45px; text-align: center; font-weight: 900; font-size: 14px; flex-shrink: 0; background: #F8FAFC; padding: 4px 0; border-radius: 6px; }
.list-score.played { background: var(--primary); color: white; }

/* Eräpisteet lisätty takaisin listanäkymään (Vahvistettu näkyvyys) */
.list-meta-info { width: 85px; flex-shrink: 0; text-align: right; display: flex !important; flex-direction: column; justify-content: center; gap: 2px; }
.list-sets { font-size: 9px; color: var(--muted); font-style: italic; white-space: nowrap; font-weight: 500; display: block !important; }

/* Kumotaan mahdollinen hide-mobile -luokka eräpisteiden kääreeltä */
.list-meta-info.hide-mobile { display: flex !important; }

/* KORTTINÄKYMÄ (GRID) */
.match-list { display: flex; flex-direction: column; gap: 10px; }
.match-card { background: var(--white); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.match-meta { background: #F8FAFC; padding: 5px 12px; font-size: 9px; font-weight: 800; color: var(--muted); display: flex; justify-content: space-between; text-transform: uppercase; }
.match-body { padding: 12px; display: grid; grid-template-columns: 5fr 2fr 5fr; align-items: center; text-align: center; gap: 8px; }
.team-name { font-weight: 700; font-size: 12px; line-height: 1.2; }
.score-box { background: #F1F5F9; padding: 6px; border-radius: 6px; font-weight: 900; font-size: 15px; min-width: 45px; }
.score-box.played { background: var(--primary); color: white; }

.set-points { display: flex !important; gap: 4px; padding: 0 12px 10px 12px; justify-content: center; overflow-x: auto; }
.set-pill { background: #F1F5F9; color: var(--muted); padding: 2px 6px; border-radius: 4px; font-size: 9px; font-weight: 700; border: 1px solid var(--border); white-space: nowrap; }

/* --- TILA-INDIKAATTORIT (PALLUKAT) --- */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-dot.upcoming { background-color: #fde930; } /* Harmaa */
.status-dot.playing { 
    background-color: #10B981; /* vihreä */
    box-shadow: 0 0 0 0 rgba(161, 229, 140, 0.7);
    animation: pulse-dot 1.5s infinite cubic-bezier(0.66, 0, 0, 1);
}
.status-dot.played { background-color: #4E82A5; } /* Vihreä */

@keyframes pulse-dot {
    to { box-shadow: 0 0 0 5px rgba(239, 68, 68, 0); }
}

/* --- PIILOTETAAN TUOMARITIEDOT --- */
.list-referee, .referee-cell, .match-meta-referee {
    display: none !important;
}

/* LATAUSANIMAATIO */
.spinner { width: 30px; height: 30px; border: 3px solid #ddd; border-top: 3px solid var(--primary); border-radius: 50%; animation: spin 1s linear infinite; margin: 50px auto; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* MOBIILIOPTIMOINTI LISTANÄKYMÄLLE */
@media (max-width: 640px) {
    .list-row { padding: 10px 4px; gap: 4px; }
    .list-datetime { width: 45px; }
    .list-time { font-size: 11px; }
    .list-field { width: 22px; font-size: 9px; }
    .list-team-home, .list-team-away { font-size: 11px; }
    .list-score { width: 38px; font-size: 12px; }
    .hide-mobile { display: none !important; }
    
    /* Pakotetaan eräpisteet näkymään mobiilissakin */
    .list-meta-info { width: 65px; display: flex !important; }
    .list-sets { font-size: 8px; display: block !important; }
}

/* TULOSTUS */
@media print {
    .no-print { display: none !important; }
    body { background: white; }
    .container { max-width: 100%; width: 100%; padding: 0; }
    .site-header, .site-footer { display: none !important; }
    .card { box-shadow: none; border: 1px solid #eee; }
}