/* 
 * PikaTyökalut.fi - Päätyylitiedosto (Main CSS)
 * 
 * Tämä tiedosto sisältää koko sivuston yhteiset tyylit.
 * Käytämme CSS-muuttujia (variables) värien ja mittojen hallintaan,
 * mikä helpottaa teeman muokkaamista myöhemmin.
 */

:root {
    /* --- VÄRIPALETTI (Color Palette) --- */
    /* Pääväri: Kirkas sininen toimintapainikkeille ja korostuksille */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    /* Tummempi sävy hover-tilaan */

    /* Taustavärit */
    --bg-body: #f8fafc;
    /* Sivun taustaväri (hyvin vaalea harmaa) */
    --bg-surface: #ffffff;
    /* Korttien ja elementtien tausta (valkoinen) */

    /* Tekstivärit */
    --text-main: #0f172a;
    /* Pääteksti (tumma, lähes musta) */
    --text-muted: #64748b;
    /* Toissijainen teksti (harmaa) */

    /* Rajat ja erottimet */
    --border: #e2e8f0;

    /* --- VÄLIT JA MITAT (Spacing) --- */
    --spacing-xs: 0.5rem;
    /* 8px */
    --spacing-sm: 1rem;
    /* 16px */
    --spacing-md: 1.5rem;
    /* 24px */
    --spacing-lg: 2rem;
    /* 32px */

    /* --- VARJOT (Shadows) --- */
    /* Käytetään syvyysvaikutelman luomiseen korteissa */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    /* --- PYÖRISTYKSET (Border Radius) --- */
    --radius-sm: 0.375rem;
    /* 6px */
    --radius-md: 0.5rem;
    /* 8px */
    --radius-lg: 0.75rem;
    /* 12px */
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-body: #0f172a;
        --bg-surface: #1e293b;
        --text-main: #f1f5f9;
        --text-muted: #94a3b8;
        --border: #334155;
        --primary: #3b82f6;
        --primary-hover: #60a5fa;
        --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
        --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.4);

        --bg-alt: #0f172a;
        --success: #4ade80;
        --success-bg: rgba(74, 222, 128, 0.1);
    }
}

/* Manuaalinen tumma teema */
[data-theme="dark"] {
    --bg-body: #0f172a;
    --bg-surface: #1e293b;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.4);

    --bg-alt: #0f172a;
    --success: #4ade80;
    --success-bg: rgba(74, 222, 128, 0.1);
}

/* Manuaalinen vaalea teema (pakotettu) */
[data-theme="light"] {
    --bg-body: #f8fafc;
    --bg-surface: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);

    --bg-alt: #f1f5f9;
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.1);
}

/* Teeman vaihtopainike */
.theme-toggle {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.2rem;
}

.theme-toggle:hover {
    background-color: var(--bg-body);
    border-color: var(--primary);
    color: var(--primary);
}

/* --- NOLLAUS JA PERUSTYYLIT (Reset & Base) --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    /* Sisällyttää paddingin ja borderin elementin leveyteen */
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    /* Käytetään järjestelmän fontteja */
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    /* Varmistaa että footer pysyy alhaalla */
    display: flex;
    flex-direction: column;
}

/* --- ASETTELU (Layout) --- */
/* Pääkontti joka keskittää sisällön ja rajoittaa maksimileveyden */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    /* Keskitys */
    padding: 0 var(--spacing-sm);
}

/* Yläpalkki */
header {
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding: var(--spacing-md) 0;
    margin-bottom: var(--spacing-lg);
}

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

/* Logo-tyylit */
.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    text-decoration: none;
}

.logo span {
    color: var(--primary);
    /* Korostusväri logossa */
}

/* Pääsisältöalue */
main {
    flex: 1;
    /* Täyttää tyhjän tilan headerin ja footerin välissä */
    padding-bottom: var(--spacing-lg);
}

/* Alapalkki */
footer {
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border);
    padding: var(--spacing-lg) 0;
    margin-top: auto;
    /* Työntää footerin sivun alareunaan */
    text-align: center;
    color: var(--text-muted);
}

/* --- KOMPONENTIT (Components) --- */

/* Hero-alue (etusivun otsikko) */
.hero {
    text-align: center;
    margin-bottom: var(--spacing-lg);
    padding: var(--spacing-lg) 0;
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: var(--spacing-xs);
    color: var(--text-main);
}

.hero p {
    font-size: 1.125rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto;
}

/* Grid-asettelu korteille */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    /* Responsiivinen grid */
    gap: var(--spacing-md);
}

/* Työkalukortti (etusivulla) */
.tool-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    transition: transform 0.2s, box-shadow 0.2s;
    /* Animaatiot hoverille */
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
}

.tool-card:hover {
    transform: translateY(-2px);
    /* Pieni nosto hoverissa */
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.tool-icon {
    font-size: 2rem;
    margin-bottom: var(--spacing-sm);
}

.tool-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
}

.tool-desc {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* --- LOMAKE-ELEMENTIT (Form Elements) --- */
/* Käytetään varsinaisissa työkaluissa */

.tool-container {
    max-width: 600px;
    margin: 0 auto;
    background: var(--bg-surface);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.input-group {
    margin-bottom: var(--spacing-md);
}

label {
    display: block;
    font-weight: 500;
    margin-bottom: var(--spacing-xs);
    color: var(--text-main);
}

/* Yhteiset tyylit kaikille syöttökentille */
input[type="number"],
input[type="text"],
textarea,
select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

/* Focus-tila (kun kenttä on valittu) */
input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    /* Hienovarainen hehku */
}

/* Painikeryhmä (vierekkäiset napit) */
.btn-group button {
    display: flex;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-md);
    overflow: auto;
    flex: 0 0 auto;

}

/* Painikkeiden perustyyli */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-size: 1rem;
}

/* Ensisijainen painike (täytetty) */
.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

/* Toissijainen painike (reunukset) */
.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
}

.btn-outline:hover,
.btn-outline.active {
    border-color: var(--primary);
    color: var(--primary);
    background-color: rgba(37, 99, 235, 0.05);
}

/* Tuloslaatikko */
.result-box {
    background-color: var(--bg-body);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    margin-top: var(--spacing-lg);
    border: 1px solid var(--border);
}

.btn-copy {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    margin-left: var(--spacing-sm);
    transition: all 0.2s;
}

.btn-copy:hover {
    border-color: var(--primary);
    color: var(--primary);
    background-color: var(--bg-surface);
}

.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-xs);
    font-size: 1.1rem;
}

/* Viimeinen rivi tuloksissa (yleensä loppusumma) */
.result-row:last-child {
    margin-bottom: 0;
    padding-top: var(--spacing-xs);
    border-top: 1px dashed var(--border);
    font-weight: 700;
    font-size: 1.25rem;
}

/* Takaisin-linkki */
.back-link {
    display: inline-flex;
    align-items: center;
    color: var(--text-muted);
    text-decoration: none;
    margin-bottom: var(--spacing-md);
}

.back-link:hover {
    color: var(--primary);
}

/* Apu-luokat (Utilities) */
.text-center {
    text-align: center;
}

.mt-4 {
    margin-top: 1rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

/* --- OHJE- JA ESIMERKKIBOKSI (Guide Box) --- */
.guide-section {
    margin-bottom: var(--spacing-md);
}

.guide-section:last-child {
    margin-bottom: 0;
}

.guide-section h2 {
    font-size: 1.5rem;
    margin-bottom: var(--spacing-md);
    color: var(--text-main);
}

.guide-section h3 {
    font-size: 1.1rem;
    margin-bottom: var(--spacing-sm);
    color: var(--text-main);
    font-weight: 600;
}

.guide-section ul {
    list-style: none;
    padding-left: 0;
}

.guide-section ul li {
    padding: var(--spacing-sm);
    margin-bottom: var(--spacing-xs);
    background-color: var(--bg-body);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--primary);
}

.guide-section ul li strong {
    color: var(--primary);
}

/* Taulukkotyyli ohjeboksiin */
.guide-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: var(--spacing-sm);
}

.guide-table td {
    padding: var(--spacing-sm);
    border-bottom: 1px solid var(--border);
}

.guide-table td:first-child {
    font-weight: 500;
    color: var(--text-main);
}

.guide-table td:last-child {
    text-align: right;
    color: var(--primary);
    font-weight: 600;
}

.guide-table tr:last-child td {
    border-bottom: none;
}

/* Vinkkilaatikko */
.tip-box {
    background-color: rgba(37, 99, 235, 0.05);
    border-left: 3px solid var(--primary);
    padding: var(--spacing-sm);
    border-radius: var(--radius-sm);
    margin-top: var(--spacing-xs);
}

.tip-box p {
    margin: 0;
    color: var(--text-main);
}

/* --- KATEGORIAOTSIKOIDEN TYYLIT (Category Headers) --- */
.tool-category-header {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin-top: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-xs);
    border-bottom: 2px solid var(--border);
    grid-column: 1 / -1;
    /* Täyttää koko gridin leveyden */
}

.tool-category-header:first-child {
    margin-top: 0;
}

/* Värikohtaiset muuttujat */
:root {
    --bg-alt: #f1f5f9;
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-alt: #0f172a;
        --success: #4ade80;
        --success-bg: rgba(74, 222, 128, 0.1);
    }
}