/* --- SPLASH SCREEN --- */
#splash-screen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0a0000 url('web_manala.png') no-repeat center center / cover;
    transition: opacity 0.8s ease;
}

#splash-screen::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, rgba(60,0,0,0.5) 0%, rgba(0,0,0,0.92) 100%);
}

.splash-content {
    position: relative;
    text-align: center;
    z-index: 1;
}

.splash-title {
    font-family: 'Cinzel Decorative', cursive;
    font-size: clamp(2.2em, 8vw, 4.5em);
    color: #ff0000;
    text-shadow: 0 0 30px #f00, 0 0 60px rgba(255,0,0,0.4), 2px 2px 6px #000;
    margin: 0 0 16px;
    opacity: 0;
    animation: splashTitleIn 1s ease 0.3s forwards;
    letter-spacing: 3px;
}

.splash-sub {
    font-family: 'Cinzel Decorative', cursive;
    font-size: clamp(1em, 3vw, 1.8em);
    color: #cc3300;
    text-shadow: 0 0 15px rgba(255,0,0,0.5), 1px 1px 4px #000;
    margin: 0 0 24px;
    opacity: 0;
    letter-spacing: 6px;
    text-transform: uppercase;
    animation: splashSubIn 1s ease 0.9s forwards;
}

.splash-line {
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #f00, transparent);
    margin: 0 auto;
    box-shadow: 0 0 10px #f00;
    animation: splashLineIn 1s ease 1.4s forwards;
}

.splash-welcome {
    font-family: 'Cinzel Decorative', cursive;
    font-size: clamp(0.9em, 2.5vw, 1.3em);
    color: #ff6633;
    text-shadow: 0 0 12px rgba(255,80,0,0.5);
    letter-spacing: 8px;
    text-transform: uppercase;
    margin: 20px 0 0;
    opacity: 0;
    animation: splashSubIn 1s ease 1.9s forwards;
}

.splash-fade-out {
    opacity: 0 !important;
    pointer-events: none;
}

@keyframes splashTitleIn {
    0%   { opacity: 0; transform: translateY(-20px) scale(0.95); }
    100% { opacity: 1; transform: translateY(0)     scale(1); }
}

@keyframes splashSubIn {
    0%   { opacity: 0; letter-spacing: 12px; }
    100% { opacity: 1; letter-spacing: 6px; }
}

@keyframes splashLineIn {
    0%   { width: 0; }
    100% { width: min(320px, 70vw); }
}

/* --- PERUSTYYLIT --- */
body { 
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
    max-width: 900px; 
    margin: 0 auto; 
    padding: 20px; 
    color: #e0e0e0;
    background: #0a0000 url('web_manala.png') no-repeat fixed center center / cover;
    box-shadow: inset 0 0 150px 80px #000;
    min-height: 100vh;
    position: relative;
}

body::before {
    content: "";
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(circle, rgba(60,0,0,0.4) 0%, rgba(0,0,0,0.9) 100%);
    z-index: -1;
}

.container { 
    background: rgba(15, 5, 5, 0.92); 
    padding: 30px; 
    border-radius: 8px; 
    border: 1px solid #400; 
    box-shadow: 0 0 40px rgba(255, 0, 0, 0.2);
}

/* --- TYPOGRAFIA --- */
h1 { 
    text-align: center; 
    color: #ff0000; 
    font-family: 'Cinzel Decorative', cursive;
    font-size: 3.5em;
    text-shadow: 0 0 15px #f00, 2px 2px 4px #000;
    margin-bottom: 30px;
}

h3 { color: #ff0000; margin-top: 25px; }

.punainen { color: #f00; }
.oranssi { color: #f90; }
.vihrea { color: #0f0; }

.section { 
    display: none; 
}

.section.active { 
    display: block !important; 
    visibility: visible !important;
    opacity: 1 !important;
}


.form-container, .form-group {
    display: block;
    width: 100%;
}
/* Varmistetaan uuden asiakkaan lomakkeen näkyvyys */
#uusi_asiakas.active .form-container {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.nav { 
    display: flex; 
    justify-content: flex-start; 
    gap: 15px; 
    margin-bottom: 30px; 
    border-bottom: 1px solid #400; 
    padding-bottom: 20px; 
}

.nav button { 
    padding: 10px 20px; 
    cursor: pointer; 
    border: 1px solid #400; 
    background: #1a0000; 
    color: #f33; 
    border-radius: 4px; 
    font-weight: bold; 
    transition: 0.3s;
}

.nav button.active { 
    background: #900; 
    color: #fff; 
    border-color: #f00; 
    box-shadow: 0 0 15px rgba(255,0,0,0.6); 
}

#btn-admin {
    margin-left: auto;
    border-color: #f90 !important;
    color: #f90 !important;
}

/* --- LOMAKKEET JA SYÖTTÖKENTÄT --- */
input[type="text"], 
input[type="password"], 
input[type="email"], 
input[type="number"] {
    background: #100;
    border: 1px solid #500;
    color: #fff;
    padding: 12px;
    border-radius: 4px;
    width: 100%; /* Oletuksena täysi leveys containerissaan */
    max-width: 500px;
    box-sizing: border-box;
    margin-bottom: 10px;
    font-size: 1em;
    display: block;
}

input[type="hidden"] { display: none; }

#asiakas_input {
    width: 350px !important;
    display: inline-block;
    margin-right: 10px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    margin-bottom: 25px;
}

/* Grid-asettelu lomakkeille */
.input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    width: 100%;
    margin-bottom: 15px;
}

.input-grid input {
    width: 100%;
    max-width: none; /* Gridissä leveys tulee sarakkeesta */
    padding: 10px;
    background: #1a0505;
    border: 1px solid #400;
    color: white;
    border-radius: 4px;
}

/* --- HAKUTULOKSET JA RIVIT --- */
.kirja-rivi {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kirja-rivi:hover {
    background: #150505 !important;
    box-shadow: inset 0 0 10px rgba(255, 0, 0, 0.1);
}

.tulos-kortti { 
    background: rgba(20, 0, 0, 0.5); 
    border: 1px solid #400; 
    padding: 15px; 
    margin-bottom: 12px; 
    border-radius: 4px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
}

.kirja-info strong { 
    color: #f33; 
    font-size: 1.2em; 
    display: block; 
    margin-bottom: 4px;
}

.kirja-status-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    min-width: 130px;
}

.kirja-status {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: bold;
    border: 1px solid;
    text-align: center;
    text-transform: uppercase;
}

.kirja-status.vapaa { background: rgba(0,255,0,0.1); color: #0f0; border-color: #0f0; }
.kirja-status.varattu { background: rgba(255,0,0,0.1); color: #f33; border-color: #f33; }

/* --- ASIAKASPROFIILI JA PALKKI --- */
.kayttaja-palkki {
    background: rgba(40, 0, 0, 0.6);
    border: 1px solid #600;
    padding: 15px;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    color: #fff;
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.1);
}

.kayttaja-palkki strong { color: #f33; }

/* --- VARAUKSET JA LAINAT --- */
.varaus-rivi {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(30, 10, 10, 0.6);
    border: 1px solid #400;
    margin-bottom: 12px;
    padding: 15px;
    border-radius: 4px;
}

.varaus-info { display: flex; flex-direction: column; gap: 5px; }
.varaus-nimi { font-size: 1.1em; color: #fff; font-weight: bold; }

.status-tag { 
    padding: 3px 10px; 
    border-radius: 3px; 
    font-size: 0.8em; 
    font-weight: bold; 
    text-transform: uppercase; 
    border: 1px solid;
    display: inline-block;
}

.status-tag.jonossa { color: #f90; border-color: #f90; background: rgba(255,153,0,0.1); }
.status-tag.noudettavissa { 
    color: #0f0; border-color: #0f0; background: rgba(0,255,0,0.1); 
    animation: pulse 2s infinite; 
}

/* --- TAULUKOT --- */
table { width: 100%; border-collapse: collapse; margin-top: 10px; }
th { 
    color: #ff0000; 
    border-bottom: 2px solid #600; 
    padding: 12px 10px; 
    text-align: left; 
    text-transform: uppercase; 
    font-size: 0.85em; 
}

th:last-child, td:last-child { text-align: right; }
td { border-bottom: 1px solid #300; padding: 12px 10px; vertical-align: middle; }

.lainat-toiminnot {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

/* --- PAINIKKEET --- */
.action-btn {
    padding: 12px 25px;
    font-weight: bold;
    border-radius: 4px;
    cursor: pointer;
    text-transform: uppercase;
    transition: 0.3s;
    border: none;
}

.btn-hae { background: #f00; color: #fff; box-shadow: 0 0 15px rgba(255,0,0,0.4); }
.btn-hae:hover { background: #f44; transform: scale(1.02); }

.btn-tyhjenna { 
    background-color: #333 !important; 
    color: #ccc !important; 
    border: 1px solid #555 !important; 
    padding: 12px 25px;
}

.btn-tyhjenna:hover {
    background-color: #C227F5 !important; 
    color: #42F527 !important;    
    border-color: #777 !important;  
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.1); 
    transform: translateY(-1px);     
}

.btn-tyhjenna:active {
    transform: translateY(1px);   
}

.btn-orange {
    background-color: #f90 !important;
    color: #000 !important;
    border: 1px solid #c60 !important;
}
.btn-orange:hover { background-color: #ffb347 !important; transform: scale(1.05); }

.btn-renew, .btn-varaus-lainaa, .btn-info { 
    background: #1b4d1b !important; color: #8f8 !important; border: 1px solid #2a7a2a !important; 
    padding: 10px 20px; border-radius: 4px; font-weight: bold; text-transform: uppercase; cursor: pointer;
}
.btn-renew:hover, .btn-varaus-lainaa:hover, .btn-info:hover { background: #2a7a2a !important; color: #fff !important; }

.btn-return, .btn-varaus-peru { 
    background: #4d1b1b; color: #f88; border: 1px solid #8b0000; 
    padding: 6px 12px; border-radius: 3px; font-weight: bold; cursor: pointer;
}
.btn-return:hover, .btn-varaus-peru:hover { background: #8b0000; color: #fff; }

.btn-tiedot {
    background: transparent; color: #f33; border: 1px solid #600;
    padding: 4px 12px; font-size: 0.8em; font-weight: bold; border-radius: 2px; text-transform: uppercase;
}

.action-buttons-wrapper { display: flex; gap: 10px; justify-content: flex-end; }

/* --- MODAL --- */
.modal { 
    display: none; 
    position: fixed; 
    z-index: 2000; 
    left: 0; top: 0; width: 100%; height: 100%; 
    background: rgba(0,0,0,0.85); 
    backdrop-filter: blur(4px); 
}

.modal-content { 
    background: #000; 
    margin: 10% auto; 
    padding: 25px; 
    border: 1px solid #800; 
    width: 90%; 
    max-width: 400px; 
    border-radius: 10px; 
    position: relative; 
}

.modal-btn-lainaa { 
    padding: 15px 40px; background: #ff0000; color: #fff; border: none; border-radius: 5px; 
    font-size: 1.2em; font-weight: bold; text-transform: uppercase; cursor: pointer; 
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.4); transition: 0.3s; 
}
.modal-btn-lainaa:hover { background: #f44; box-shadow: 0 0 30px #f00; }

.modal-actions { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 20px; }

.close { position: absolute; right: 20px; top: 15px; color: #800; font-size: 28px; font-weight: bold; cursor: pointer; }

/* --- KELLO JA PÄIVÄYS --- */
#date_time {
    position: fixed; bottom: 15px; left: 15px;
    background: rgba(15, 5, 5, 0.95); color: #ccc;                     
    padding: 10px 15px; border-radius: 4px; border: 1px solid #400;          
    font-family: 'Segoe UI', Tahoma, sans-serif; font-size: 0.8em;
    letter-spacing: 1px; box-shadow: 0 0 15px rgba(139, 0, 0, 0.3); 
    z-index: 1000; text-transform: capitalize; pointer-events: none;               
}

/* --- SUODATINPALKKI --- */
#suodatin-palkki select {
    background: #100;
    border: 1px solid #500;
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.85em;
    cursor: pointer;
}

#suodatin-palkki input[type="number"],
#suodatin-palkki input[type="text"] {
    width: auto;
    max-width: none;
    margin-bottom: 0;
    display: inline-block;
}

#suodatin-palkki label {
    white-space: nowrap;
}

/* --- ANIMAATIOT --- */
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } }

/* --- MOBIILIOPTIMOINTI --- */
@media (max-width: 600px) {
    .nav { flex-wrap: wrap; }
    .input-grid { grid-template-columns: 1fr; }
    h1 { font-size: 2.2em; }
    .tulos-kortti { flex-direction: column; align-items: flex-start; }
    .kirja-status-wrapper { align-items: flex-start; margin-top: 10px; width: 100%; }
    input[type="text"], #asiakas_input { width: 100% !important; }
}