/**
 * Description: Main CSS V1.3 (Fixed).
 * - KORJAUS: Palautettu body.dark-mode -luokat, jotta teemanvaihtonappi toimii.
 * - LOGO: Lisätty tyylit kuvalle.
 * Author: Markus Haapasaari / Kaupunkilehti Kalajokinen
 * Version: 1.3
 */

:root {
    /* --- OLETUSVÄRIT (VAALEA) --- */
    --primary-color: #F5A623;
    --primary-dark: #D48806;

    --bg-color: #F2F0EB;
    --surface-color: #FFFFFF;
    --input-bg: #F9FAFB;

    --secondary-color: #111111;
    --text-main: #1F2937;
    --text-muted: #6B7280;

    --border-color: #e5e7eb;

    --nav-height: 90px;
    --font-heading: 'Sora', sans-serif;
    --font-body: 'Inter', sans-serif;

    --shadow-soft: 0 4px 20px rgba(0,0,0,0.05);
}

/* --- AUTOMATIIKKA (Järjestelmän asetus) --- */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #121212;
        --surface-color: #1E1E1E;
        --input-bg: #2C2C2C;
        --secondary-color: #FFFFFF;
        --text-main: #E5E7EB;
        --text-muted: #9CA3AF;
        --border-color: #333333;
        --shadow-soft: 0 4px 20px rgba(0,0,0,0.3);
    }
}

/* --- MANUAALINEN PAKOTUS (Napin toiminta) --- */
/* Tämä ylikirjoittaa kaiken, jos käyttäjä painaa nappia */
body.dark-mode {
    --bg-color: #121212;
    --surface-color: #1E1E1E;
    --input-bg: #2C2C2C;
    --secondary-color: #FFFFFF;
    --text-main: #E5E7EB;
    --text-muted: #9CA3AF;
    --border-color: #333333;
    --shadow-soft: 0 4px 20px rgba(0,0,0,0.3);
}

body.light-mode {
    --bg-color: #F2F0EB;
    --surface-color: #FFFFFF;
    --input-bg: #F9FAFB;
    --secondary-color: #111111;
    --text-main: #1F2937;
    --text-muted: #6B7280;
    --border-color: #e5e7eb;
    --shadow-soft: 0 4px 20px rgba(0,0,0,0.05);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-body);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* --- NAVIGAATIO --- */
.app-navbar {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 1000;
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    height: var(--nav-height);
    display: flex;
    align-items: center;
    width: 100%;
    opacity: 0.98;
}

.nav-container {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* LOGO FIX */
.nav-brand {
    display: flex;
    align-items: center;
    text-decoration: none;
    height: 100%;
}

.nav-logo {
    height: 40px;
    width: auto;
    display: block;
    object-fit: contain;
}

@media (min-width: 768px) {
    .nav-logo { height: 55px; }
}

.nav-links { display: flex; gap: 30px; align-items: center; }
.nav-links a {
    color: var(--text-main);
    font-weight: 500;
    font-size: 0.95rem;
    position: relative;
    text-decoration: none;
}

.nav-links a:hover { color: var(--primary-color); }
.menu-toggle { display: none; font-size: 1.8rem; background: none; border: none; cursor: pointer; padding: 0; color: var(--text-main); }

/* --- PÄÄSISÄLTÖ --- */
.app-content {
    flex: 1;
    width: 100%;
    max-width: 100%;
    margin: 30px 0;
    padding: 0 20px;
}

/* --- UI --- */
h1, h2, h3 {
    font-family: var(--font-heading);
    color: var(--secondary-color);
    margin-top: 0;
    line-height: 1.2;
}
h1 { font-size: 2.5rem; margin-bottom: 1rem; }

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 12px 28px; background-color: var(--secondary-color); color: var(--bg-color);
    border-radius: 50px; font-weight: 600; text-decoration: none; transition: 0.2s; border: none; cursor: pointer;
}
.btn:hover { background-color: var(--primary-color); color: #000; transform: scale(1.02); }

.btn-secondary { background-color: var(--surface-color); color: var(--text-main); border: 1px solid rgba(0,0,0,0.1); }
.btn-secondary:hover { background-color: var(--bg-color); }

input, select, textarea {
    width: 100%; padding: 14px;
    background: var(--input-bg);
    color: var(--text-main);
    border: 2px solid transparent;
    border-radius: 10px; font-size: 1rem; margin-bottom: 20px;
}
input:focus, textarea:focus {
    background: var(--surface-color);
    border-color: var(--primary-color);
    outline: none;
}

/* RESPONSIVISUUS */
@media (max-width: 1000px) {
    .nav-links { gap: 15px; }
    .nav-links a { font-size: 0.85rem; }
}

@media (max-width: 768px) {
    .app-content { margin: 20px 0; padding: 0 15px; }
    .nav-container { padding: 0 15px; }

    .nav-links {
        display: none; position: absolute; top: var(--nav-height); left: 0; right: 0;
        height: calc(100vh - var(--nav-height));
        background: var(--surface-color);
        flex-direction: column;
        justify-content: flex-start; padding: 40px 20px; border-top: 1px solid var(--border-color);
    }
    .nav-links.open { display: flex; }
    .nav-links a { font-size: 1.2rem; font-weight: 700; width: 100%; text-align: center; padding: 10px 0; }
    .menu-toggle { display: block; }
}

/* TÄMÄ ON KRIITTINEN NAPIN TOIMINNALLE: */
body.dark-mode {
    --bg-color: #121212;
    --surface-color: #1E1E1E;
    --input-bg: #2C2C2C;
    --secondary-color: #FFFFFF;
    --text-main: #E5E7EB;
    --text-muted: #9CA3AF;
    --border-color: #333333;
    --shadow-soft: 0 4px 20px rgba(0,0,0,0.3);
}
