/* ==========================================
   PERUSASETUKSET JA TYPOGRAFIA
   ========================================== */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f4f7f6;
    color: #333;
    margin: 0;
    padding: 20px;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

h1, h2, h3 {
    color: #2c3e50;
}

/* ==========================================
   PAINIKKEET
   ========================================== */
button {
    cursor: pointer;
    border: none;
    border-radius: 4px;
    padding: 10px 15px;
    font-size: 16px;
    font-weight: bold;
    transition: background 0.3s, opacity 0.3s;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-primary { background-color: #007bff; color: white; }
.btn-primary:hover:not(:disabled) { background-color: #0056b3; }

.btn-secondary { background-color: #6c757d; color: white; }
.btn-secondary:hover:not(:disabled) { background-color: #5a6268; }

.btn-danger { background-color: #dc3545; color: white; }
.btn-danger:hover:not(:disabled) { background-color: #c82333; }

.btn-share {
    background-color: #28a745;
    color: white;
    margin-bottom: 15px;
}

/* ==========================================
   VARAUSKALENTERI JA SLOTIT
   ========================================== */
#slots-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 20px;
}

.track-column {
    flex: 1;
    min-width: 250px;
    background: #fdfdfd;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
}

.track-column h3 {
    margin-top: 0;
    border-bottom: 2px solid #007bff;
    padding-bottom: 10px;
    font-size: 1.2em;
}

.track-slots-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.slot-btn {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    text-align: left;
    border: 1px solid #ccc;
    border-radius: 5px;
    background-color: #fff;
}

.slot-btn.free {
    border-color: #28a745;
    color: #28a745;
    background-color: #f8fff9;
}
.slot-btn.free:hover {
    background-color: #28a745;
    color: #fff;
}

.slot-btn.locked {
    background-color: #ffc107;
    color: #fff;
    border-color: #d39e00;
}

.slot-btn.confirmed {
    background-color: #dc3545;
    color: #fff;
    border-color: #c82333;
}

.slot-btn.closed {
    background-color: #e9ecef;
    color: #6c757d;
    border-color: #ced4da;
}

/* ==========================================
   LOMAKKEET
   ========================================== */
label {
    display: block;
    font-weight: bold;
    margin-top: 15px;
    margin-bottom: 5px;
    color: #333;
}

input[type="text"],
input[type="email"],
input[type="date"],
input[type="time"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-family: inherit;
}

input[type="checkbox"], input[type="radio"] {
    margin-right: 8px;
}

.otp-container {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 20px 0;
}

.otp-input {
    width: 50px !important;
    height: 50px;
    text-align: center;
    font-size: 24px;
    text-transform: uppercase;
}

/* ==========================================
   MODAALI-IKKUNAT
   ========================================== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 20px 30px 30px;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

#adminModal .modal-content {
    max-width: 900px; 
}

.close-btn {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-btn:hover {
    color: #000;
}

/* ==========================================
   ADMIN HALLINTA & TAULUKOT (TIETOKONENÄKYMÄ)
   ========================================== */
.admin-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
}

.admin-tabs button {
    background: #e9ecef;
    color: #333;
    border-radius: 4px 4px 0 0;
}

.admin-tabs button:hover, .admin-tabs button.active {
    background: #007bff;
    color: white;
}

#adminBookingsList {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.admin-table th, .admin-table td {
    padding: 12px 10px;
    border-bottom: 1px solid #ddd;
    text-align: left;
}

.admin-table th {
    background-color: #f8f9fa;
    font-weight: bold;
    color: #495057;
}

.admin-table td {
    word-wrap: break-word;
    max-width: 200px; /* Rajoitetaan kenttien leveyttä tietokoneella */
}

/* Nappien asettelu tietokoneella (Päällekkäin) */
.admin-btn-container {
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: center;
    justify-content: center;
}

.admin-btn-container button {
    width: 100%;
    margin: 0 !important;
    display: block;
}

.admin-table td:last-child {
    white-space: nowrap;
    width: 1%;
    max-width: none;
}

/* Ratojen muokkaus */
.track-editor-item {
    background: #f8f9fa;
    border: 1px solid #ccc;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 15px;
}

.track-editor-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

/* ==========================================
   MOBIILIOPTIMOINTI (Korttinäkymä adminille)
   ========================================== */
@media screen and (max-width: 768px) {
    /* Piilotetaan perinteisen taulukon otsikot */
    .admin-table thead {
        display: none; 
    }

    /* Pakotetaan taulukon elementit lohkoiksi, jotka vievät 100% leveyden */
    .admin-table, .admin-table tbody, .admin-table tr, .admin-table td {
        display: block;
        width: 100% !important; /* Kumoaa tietokonenäkymän prosentit */
        box-sizing: border-box;
    }

    /* Yksittäisen varauksen kortti */
    .admin-table tr {
        margin-bottom: 20px;
        border: 1px solid #dcdcdc;
        border-radius: 8px;
        background: #fff;
        box-shadow: 0 2px 6px rgba(0,0,0,0.08);
        overflow: hidden; 
    }

    /* Kortin kentät (Aika, Varaaja, Koira, jne) */
    .admin-table td {
        max-width: 100% !important; /* KUMOAA tietokonenäkymän rajoituksen */
        border-bottom: 1px solid #eee !important;
        padding: 10px 15px !important;
        text-align: left !important;
        white-space: normal !important; 
    }

    /* Kortin yläpalkki (Aika ja paikka) */
    .admin-table td:nth-child(1) {
        background-color: #f4f6f8;
        border-bottom: 2px solid #e0e0e0 !important;
    }

    /* Pikkutekstit ("Varaaja:", "Koira:") mobiilissa tietojen yläpuolelle */
    .admin-table td:nth-child(2)::before { content: "Varaaja / Koodi"; display: block; font-size: 0.75em; color: #888; text-transform: uppercase; font-weight: bold; margin-bottom: 4px; }
    .admin-table td:nth-child(3)::before { content: "Koira / Rotu"; display: block; font-size: 0.75em; color: #888; text-transform: uppercase; font-weight: bold; margin-bottom: 4px; }
    .admin-table td:nth-child(4)::before { content: "Lisätiedot"; display: block; font-size: 0.75em; color: #888; text-transform: uppercase; font-weight: bold; margin-bottom: 4px; }

    /* Nappien säiliö (Kortin alapalkki) */
    .admin-table td:last-child {
        background-color: #fafafa;
        border-bottom: none !important;
        padding: 12px 15px !important;
    }

    /* Napit nätisti vierekkäin koko leveydelle */
    .admin-btn-container {
        display: flex;
        flex-direction: row !important; /* Pakottaa napit vierekkäin */
        width: 100%;
        gap: 10px;
    }

    .admin-btn-container button {
        flex: 1; /* Kummatkin napit vievät tasan 50% tilasta */
        margin: 0 !important;
        padding: 12px 5px;
        font-size: 15px;
        justify-content: center;
        display: flex;
        align-items: center;
    }
}

/* ==========================================
   YLÄPALKKI (Valikko ja Jaa-nappi vierekkäin)
   ========================================== */
.top-controls {
    display: flex;
    align-items: flex-end; /* Tasaa napin alalaidan valikon kanssa */
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap; /* Rivittyy nätisti aivan pienimmillä näytöillä */
}

.event-selector-wrapper {
    flex-grow: 1; /* Valikko ottaa kaiken liikenevän tilan */
}

.event-selector-wrapper label {
    margin-top: 0; /* Poistaa turhan välin ylhäältä */
}

.top-controls .btn-share {
    margin-bottom: 0;
    height: 41px; /* Saman korkuinen kuin oletus select-laatikko */
    white-space: nowrap;
}

/* ==========================================
   VÄRISELITE (Legend)
   ========================================== */
.legend-container {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
    font-size: 0.9em;
    color: #555;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.legend-box {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid #ccc;
}

/* Yhdistetään olemassa oleviin väreihin */
.legend-box.free { background-color: #f8fff9; border-color: #28a745; }
.legend-box.confirmed { background-color: #dc3545; border-color: #c82333; }
.legend-box.locked { background-color: #ffc107; border-color: #d39e00; }
.legend-box.closed { background-color: #e9ecef; border-color: #ced4da; }