/* ============================================================
   UNIVERSAL STYLES FOR KARTING COMPETITION WEBSITE
   Theme: Red (#d32f2f), Top1 background
   Responsive: Mobile, Tablet, Desktop
   Clean & Functional Design
   ============================================================ */

/* ===== RESET & BASE ===== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100%;
    height: auto;
    font-family: 'Arial', 'Segoe UI', sans-serif;
    color: #333;
    line-height: 1.6;
}

body {
    background-color: #f4f4f4;
    background-image: url('top1.png');
    background-repeat: no-repeat;
    background-position: bottom center;
    background-size: cover;
    background-attachment: fixed;
    padding: 55px 10px 15px 10px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ===== TYPOGRAPHY ===== */
h1, h2, h3 {
    color: #d32f2f;
    margin-bottom: 12px;
}

h1 {
    font-size: 26px;
    text-align: center;
    margin-bottom: 15px;
}

h2 {
    font-size: 18px;
    margin-bottom: 12px;
}

h3 {
    font-size: 15px;
    margin-bottom: 10px;
}

p {
    margin-bottom: 10px;
    color: #555;
    font-size: 14px;
}

/* ===== BUTTONS (UNIVERSAL STYLE) ===== */
.top-button,
.back-button,
.rules-button,
.dropbtn,
input[type="submit"],
button,
.btn-delete,
.btn-remove-training {
    padding: 9px 14px;
    font-size: 12px;
    font-weight: bold;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    background-color: #d32f2f;
    color: white;
    transition: background-color 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.top-button:hover,
.back-button:hover,
.rules-button:hover,
.dropbtn:hover,
input[type="submit"]:hover,
button:hover,
.btn-delete:hover {
    background-color: #b71c1c;
}

.top-button:active,
.back-button:active,
.rules-button:active,
.dropbtn:active,
input[type="submit"]:active,
button:active {
    background-color: #8e0000;
}

/* Top nav buttons positioning */
.top-button {
    position: absolute;
    z-index: 1000;
    padding: 8px 12px;
    font-size: 11px;
}

.schedule-button {
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: auto;
    min-width: 140px;
    text-align: center;
    white-space: nowrap;
}

.login-button, .logout-button {
    top: 10px;
    left: 10px;
}

/* Rules button - prawo-góra */
.rules-button {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 8px 11px;
    font-size: 11px;
    z-index: 1000;
    background-color: #d32f2f;
    white-space: nowrap;
}

/* Dropdown button */
.dropbtn {
    position: fixed;
    top: 10px;
    right: 10px;
    width: 130px;
    padding: 8px 10px;
    font-size: 11px;
    min-width: auto;
    text-align: center;
}

/* ===== CONTAINERS ===== */
.container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 0 10px;
}

.form-container,
.login-container,
.modal-content,
form {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    border: 1px solid #ddd;
}

.form-container {
    padding: 20px;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
}

.login-container {
    padding: 35px;
    width: 100%;
    max-width: 380px;
    text-align: center;
    margin: 0 auto;
}

.login-container h2 {
    font-size: 22px;
    margin-bottom: 8px;
    color: #d32f2f;
}

.login-container p {
    color: #999;
    margin-bottom: 20px;
    font-size: 12px;
}

.modal-content {
    margin: 10% auto;
    padding: 25px;
    width: 80%;
    max-width: 480px;
    text-align: center;
}

.admin-container {
    display: flex;
    gap: 15px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    padding: 0 10px;
    box-sizing: border-box;
}

.admin-left {
    flex: 1;
    min-width: 250px;
}

.admin-right {
    flex: 1.5;
    min-width: 350px;
    padding: 18px;
    max-height: 480px;
    overflow-y: auto;
}

.participants-box {
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    max-height: 400px;
    overflow-y: auto;
}

/* ===== FORMS ===== */
form {
    padding: 18px;
    margin-top: 15px;
    width: 100%;
}

form label {
    display: block;
    margin-bottom: 4px;
    color: #333;
    font-weight: 600;
    margin-top: 10px;
    font-size: 12px;
}

form label:first-child {
    margin-top: 0;
}

.form-group {
    margin-bottom: 10px;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    color: #333;
    font-weight: 500;
    font-size: 12px;
}

input[type="text"],
input[type="password"],
input[type="email"],
select {
    width: 100%;
    padding: 7px;
    margin: 5px 0;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-size: 13px;
    box-sizing: border-box;
    transition: border-color 0.3s;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
select:focus {
    outline: none;
    border-color: #d32f2f;
}

input[type="submit"],
button {
    width: 100%;
    padding: 9px;
    margin: 8px 0;
    font-size: 13px;
    border: none;
}

button:not([type="submit"]) {
    width: auto;
}

/* Checkboxes styling */
.form-group input[type="checkbox"] {
    width: auto;
    margin-right: 6px;
    transform: scale(1.2);
    accent-color: #d32f2f;
    margin: 0;
}

.form-group input[type="checkbox"] + label {
    display: inline;
    margin-left: 4px;
    font-weight: normal;
    margin-top: 0;
}

.training-fields {
    display: none;
}

.training-fields .form-group {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-bottom: 7px;
    padding: 7px;
    background-color: #f9f9f9;
    border-radius: 6px;
    border-left: 2px solid #d32f2f;
    width: 100%;
    box-sizing: border-box;
}

/* ===== EVENT ITEMS ===== */
.event-item {
    padding: 9px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    font-weight: 600;
    color: white;
    text-align: center;
    transition: background-color 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 7px;
}

.event-item.open {
    background-color: #4CAF50;
}

.event-item.open:hover {
    background-color: #45a049;
}

.event-item.closed {
    background-color: #ccc;
    color: #666;
}

.event-item.closed:hover {
    background-color: #bbb;
    color: #666;
}

/* ===== ADMIN PANEL ===== */
#events-list {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

#counts {
    margin-top: 10px;
    padding: 8px;
    background-color: #f9f9f9;
    border-radius: 6px;
    border-left: 3px solid #d32f2f;
    font-weight: bold;
    text-align: center;
    color: #333;
    font-size: 11px;
}

#participants-list {
    margin-top: 8px;
}

.participant-item {
    background-color: #f9f9f9;
    padding: 9px;
    margin-bottom: 7px;
    border-radius: 6px;
    border-left: 3px solid #d32f2f;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.participant-name {
    font-weight: bold;
    font-size: 12px;
    margin-bottom: 4px;
    color: #333;
}

.participant-trainings {
    font-size: 11px;
    color: #666;
    margin-bottom: 5px;
    padding: 5px;
    background-color: white;
    border-radius: 4px;
    border-left: 2px solid #d32f2f;
}

.participant-trainings strong {
    color: #d32f2f;
}

.participant-buttons {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.participant-buttons button {
    flex: 1;
    min-width: 85px;
    padding: 5px 7px;
    font-size: 10px;
    margin: 0;
}

.btn-delete {
    background-color: #d32f2f;
}

.btn-delete:hover {
    background-color: #b71c1c;
}

.btn-remove-training {
    background-color: #ff9800;
}

.btn-remove-training:hover {
    background-color: #f57c00;
}

.btn-delete-trainings {
    background-color: #1976d2;
}

.btn-delete-trainings:hover {
    background-color: #1565c0;
}

/* ===== TRAININGS MODAL ===== */
.training-checkbox {
    padding: 10px;
    margin: 8px 0;
    background-color: #f5f5f5;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.training-checkbox label {
    display: flex;
    align-items: center;
    cursor: pointer;
    margin: 0;
    font-size: 13px;
}

.training-checkbox input[type="checkbox"] {
    margin-right: 10px;
    cursor: pointer;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: flex-end;
}

.btn-confirm,
.btn-cancel {
    padding: 9px 14px;
    font-size: 12px;
    font-weight: bold;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: background-color 0.3s;
}

.btn-confirm {
    background-color: #4caf50;
    color: white;
}

.btn-confirm:hover {
    background-color: #45a049;
}

.btn-cancel {
    background-color: #666;
    color: white;
}

.btn-cancel:hover {
    background-color: #555;
}

/* ===== SESSION TIMER ===== */
#session-timer {
    position: fixed;
    bottom: 45px;
    right: 10px;
    background-color: rgba(51, 51, 51, 0.9);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 10px;
    user-select: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    border: 1px solid #d32f2f;
    z-index: 999;
}

/* ===== MODAL ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
}

.close {
    color: #aaa;
    float: right;
    font-size: 22px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
}

.close:hover, .close:focus {
    color: #d32f2f;
}

/* ===== TRAINING SCHEDULE ===== */
.training-box {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    border: 1px solid #ddd;
    overflow: hidden;
    margin-bottom: 12px;
}

.training-header {
    background-color: #d32f2f;
    color: white;
    font-weight: bold;
    padding: 9px;
    font-size: 12px;
    text-align: center;
}

.training-list {
    padding: 9px;
    list-style: none;
}

.training-list li {
    padding: 5px;
    margin-bottom: 3px;
    background-color: #f9f9f9;
    border-radius: 4px;
    border-left: 2px solid #d32f2f;
    font-size: 11px;
}

.training-content {
    padding: 10px;
    font-size: 11px;
}

ul.participant-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

ul.participant-list li {
    padding: 4px 0;
    border-bottom: 1px solid #eee;
    font-size: 11px;
}

ul.participant-list li:last-child {
    border-bottom: none;
}

/* ===== COUNTDOWN ===== */
.participant-count {
    font-size: 11px;
    color: #000;
    margin-left: auto;
    font-weight: 600;
    white-space: nowrap;
}

/* Event selector styling */
.event-selector {
    background: rgba(255, 255, 255, 0.95);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 12px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    border: 1px solid #ddd;
}

.event-selector select {
    padding: 7px;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-size: 12px;
}

/* Dropdown menu styling */
.dropdown {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 999;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background-color: rgba(255, 255, 255, 0.98);
    width: 120px;
    max-height: 230px;
    overflow-y: auto;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    margin-top: -4px;
    padding: 6px;
    border: 1px solid #ddd;
}

.dropdown-content ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.dropdown-content li {
    padding: 5px;
    border-bottom: 1px solid #eee;
    color: #333;
    font-size: 11px;
    cursor: pointer;
}

.dropdown-content li:last-child {
    border-bottom: none;
}

.dropdown-content li:hover {
    background-color: #f5f5f5;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1024px) {
    body {
        padding: 50px 10px 12px 10px;
    }

    .admin-container {
        flex-direction: column;
        gap: 12px;
    }

    .admin-left, .admin-right {
        min-width: auto;
        flex: 1;
        width: 100%;
    }

    h1 {
        font-size: 22px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 55px 8px 10px 8px;
    }

    .top-button {
        padding: 7px 8px;
        font-size: 10px;
    }

    .schedule-button {
        top: 8px;
        min-width: 110px;
    }

    .login-button, .logout-button {
        top: 8px;
    }

    .rules-button {
        top: 8px;
        padding: 7px 8px;
    }

    .dropbtn {
        width: 115px;
        padding: 7px 8px;
        font-size: 10px;
        top: 8px;
    }

    h1 {
        font-size: 18px;
        margin-bottom: 10px;
    }

    h2 {
        font-size: 16px;
    }

    .form-container {
        max-width: 100%;
        padding: 15px;
    }

    input[type="text"],
    input[type="password"],
    input[type="email"],
    select {
        padding: 6px;
        font-size: 12px;
    }

    input[type="submit"],
    button {
        padding: 7px;
        font-size: 11px;
        margin: 6px 0;
    }

    .admin-right {
        max-height: 350px;
        padding: 15px;
    }

    #session-timer {
        font-size: 9px;
        padding: 5px 8px;
        bottom: 40px;
    }

    .modal-content {
        width: 90%;
        padding: 18px;
    }

    .rules-button {
        top: 8px;
        padding: 7px 8px;
        font-size: 10px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 55px 6px 8px 6px;
    }

    /* MOBILE: Rozmieść przyciski symetrycznie - górę */
    .top-button {
        padding: 6px 6px;
        font-size: 9px;
    }

    .schedule-button {
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        min-width: 105px;
        padding: 6px 5px;
    }

    .login-button, .logout-button {
        top: 6px;
        left: 6px;
        padding: 6px 5px;
    }

    .rules-button {
        top: 6px;
        right: 6px;
        padding: 6px 5px;
    }

    .dropbtn {
        width: 85px;
        padding: 6px 4px;
        font-size: 9px;
        top: 6px;
        right: 6px;
    }

    h1 {
        font-size: 16px;
        margin-bottom: 8px;
    }

    .form-container,
    .login-container {
        padding: 12px;
        max-width: 100%;
    }

    input[type="text"],
    input[type="password"],
    input[type="email"],
    select {
        padding: 5px;
        font-size: 11px;
        margin: 3px 0;
    }

    input[type="submit"],
    button {
        padding: 6px;
        font-size: 10px;
        margin: 5px 0;
    }

    .rules-button {
        padding: 6px 5px;
        font-size: 9px;
        top: 6px;
        right: 6px;
    }

    #session-timer {
        font-size: 8px;
        padding: 4px 6px;
        bottom: 38px;
        right: 6px;
    }

    .participant-buttons button {
        padding: 4px 5px;
        font-size: 9px;
        min-width: 75px;
    }

    .event-item {
        font-size: 11px;
        padding: 7px;
    }

    .training-box {
        margin-bottom: 10px;
    }

    .modal-content {
        width: 95%;
        padding: 12px;
    }

    .admin-right {
        max-height: 300px;
        padding: 12px;
    }

    .admin-container {
        gap: 10px;
    }
}

/* ===== TERMINARZ PAGE STYLES ===== */
/* Specific button styling for terminarz page */
.top-button.back-button {
    position: absolute;
    top: 10px;
    left: 10px;
    margin: 0;
    padding: 0 12px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #c62828;
    z-index: 997;
    font-size: 12px;
    font-weight: bold;
    border: none;
    color: white;
    cursor: pointer;
    border-radius: 6px;
    transition: background-color 0.3s;
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.top-button.back-button:hover {
    background-color: #d32f2f;
}

/* Event selector and dropdown styles */
.event-selector {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 998;
    background: rgba(255,255,255,0.95);
    padding: 6px 12px;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    border: 1px solid #ddd;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    width: auto;
    max-width: 350px;
    margin: 0;
    height: 38px;
}

.event-selector label {
    font-weight: 700;
    margin: 0;
    white-space: nowrap;
    font-size: 12px;
    color: #555;
}

.event-selector select {
    padding: 6px 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 12px;
    background-color: white;
    color: #333;
    cursor: pointer;
    min-width: 150px;
    height: 28px;
}

.dropdown {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 999;
    padding: 0;
    margin: 0;
}

.dropdown .dropbtn {
    position: static;
    margin: 0;
    padding: 0 12px;
    width: auto;
    min-width: 140px;
    height: 38px;
    font-size: 12px;
    font-weight: bold;
    border: none;
    color: white;
    cursor: pointer;
    border-radius: 6px;
    transition: background-color 0.3s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background-color: #c62828;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.dropdown .dropbtn:hover {
    background-color: #d32f2f;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 38px;
    background-color: rgba(255,255,255,0.98);
    width: 140px;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    border-radius: 0 0 6px 6px;
    padding: 6px 0;
    border: 1px solid #ddd;
    border-top: none;
    margin: 0;
    z-index: 1000;
}

.dropdown-content ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.dropdown-content li {
    padding: 6px 10px;
    border-bottom: 1px solid #f0f0f0;
    color: #333;
    font-size: 12px;
    line-height: 1.3;
    cursor: pointer;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.dropdown-content li:hover {
    background-color: #f5f5f5;
}

.dropdown-content li:last-child {
    border-bottom: none;
}

.dropdown-content.show {
    display: block;
}

.container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    max-width: 1100px;
    width: 100%;
}

.training-box {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    border: 1px solid #ddd;
    overflow: hidden;
}

.training-header {
    background-color: #d32f2f;
    color: white;
    font-weight: bold;
    padding: 10px;
    text-align: center;
    font-size: 14px;
}

.training-content {
    padding: 12px;
    font-size: 13px;
}

ul.participant-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

ul.participant-list li {
    padding: 5px 0;
    border-bottom: 1px solid #eee;
    font-size: 12px;
}

ul.participant-list li:last-child {
    border-bottom: none;
}

/* Responsive adjustments for terminarz */
@media (max-width: 1024px) {
    .top-button.back-button {
        top: 10px;
        left: 10px;
        padding: 0 11px;
        height: 36px;
    }

    .event-selector {
        max-width: 300px;
        padding: 6px 10px;
        font-size: 11px;
        height: 36px;
    }

    .event-selector label {
        font-size: 11px;
    }

    .event-selector select {
        font-size: 11px;
        min-width: 120px;
        padding: 5px 5px;
        height: 26px;
    }

    .dropdown .dropbtn {
        padding: 0 11px;
        min-width: 130px;
        height: 36px;
        font-size: 11px;
    }

    .dropdown-content {
        top: 38px;
    }

    .container {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .top-button.back-button {
        top: 8px;
        left: 8px;
        padding: 0 10px;
        height: 34px;
    }

    .event-selector {
        top: 8px;
        max-width: 250px;
        padding: 5px 9px;
        font-size: 10px;
        height: 34px;
    }

    .event-selector label {
        font-size: 10px;
    }

    .event-selector select {
        min-width: 100px;
        font-size: 10px;
        padding: 4px 4px;
        height: 24px;
    }

    .dropdown {
        top: 8px;
        right: 8px;
    }

    .dropdown .dropbtn {
        padding: 0 10px;
        min-width: 120px;
        height: 34px;
        font-size: 11px;
        top: 8px;
        right: 8px;
    }

    .dropdown-content {
        top: 36px;
    }

    .container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .top-button.back-button {
        top: 8px;
        left: 6px;
        padding: 0 6px;
        height: 26px;
        font-size: 9px;
    }

    .event-selector {
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        max-width: 170px;
        padding: 5px 7px;
        font-size: 9px;
        height: 30px;
    }

    .event-selector label {
        font-size: 8px;
        display: none;
    }

    .event-selector select {
        min-width: 80px;
        font-size: 9px;
        padding: 3px 3px;
        height: 22px;
    }

    .dropdown {
        top: 8px;
        right: 6px;
    }

    .dropdown .dropbtn {
        padding: 0 6px;
        min-width: 80px;
        height: 26px;
        font-size: 9px;
    }

    .dropdown-content {
        top: 30px;
    }

    .container {
        grid-template-columns: 1fr;
    }
}
