
:root {
    --background: #0b0e14;
    --surface: #131923;
    --surface-light: #1a2230;
    --border: #293344;
    --text: #f0f3f8;
    --muted: #8f9bad;
    --red: #ff646e;
    --red-bg: #351c25;
    --blue: #68a9ff;
    --blue-bg: #192c45;
    --green: #5ed6a0;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--background);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, transform 0.2s;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 24px 5%;
    background: #10151e;
    border-bottom: 1px solid var(--border);
}

.topbar h1 {
    margin: 0 0 7px;
    font-size: 25px;
}

.topbar p,
.section-heading p,
.modal-header p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
}

.container {
    width: min(1500px, 90%);
    margin: 35px auto;
}

.add-button,
.secondary-button,
.delete-button {
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 12px 18px;
    font-weight: 700;
}

.add-button {
    background: #397de5;
    color: white;
}

.add-button:hover {
    background: #2868cb;
}

.secondary-button {
    background: var(--surface-light);
    border-color: var(--border);
    color: var(--text);
}

.secondary-button:hover {
    background: #263247;
}

.delete-button {
    background: var(--red-bg);
    border-color: #67303a;
    color: var(--red);
}

.delete-button:hover {
    background: #51232d;
}

.statistics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    padding: 25px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
}

.late-card {
    border-left: 4px solid var(--red);
}

.early-card {
    border-left: 4px solid var(--blue);
}

.stat-label {
    color: var(--muted);
    font-size: 14px;
}

.stat-value {
    margin-top: 12px;
    font-size: clamp(30px, 4vw, 42px);
    font-weight: 800;
}

.stat-value small {
    font-size: 16px;
    font-weight: 500;
    color: var(--muted);
}

.late-card .stat-value {
    color: var(--red);
}

.early-card .stat-value {
    color: var(--blue);
}

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-bottom: 22px;
}

.section-heading h2 {
    margin: 0 0 8px;
    font-size: 22px;
}

.event-count {
    padding: 8px 12px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
}

.events-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.event-card {
    min-width: 0;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s, background 0.2s;
}

.event-card:hover {
    transform: translateY(-3px);
    border-color: #526681;
    background: #171f2b;
}

.event-card:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 3px;
}

.event-card h3 {
    margin: 0 0 15px;
    font-size: 17px;
    overflow-wrap: anywhere;
}

.event-date {
    margin: 7px 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.event-result {
    display: inline-block;
    margin-top: 12px;
    padding: 7px 10px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 700;
}

.result-late {
    background: var(--red-bg);
    color: var(--red);
}

.result-early {
    background: var(--blue-bg);
    color: var(--blue);
}

.result-on-time {
    background: #183329;
    color: var(--green);
}

.empty-state {
    padding: 65px 20px;
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: 16px;
    color: var(--muted);
}

.empty-icon {
    font-size: 38px;
}

.empty-state h3 {
    color: var(--text);
    margin-bottom: 8px;
}

.empty-state p {
    line-height: 1.5;
}

/* Okna modalne */

.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(5px);
}

.modal.is-open {
    display: flex;
}

.modal-content {
    width: min(100%, 900px);
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 30px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.45);
    animation: modalAppear 0.18s ease-out;
}

.form-modal-content {
    width: min(100%, 1050px);
    min-height: min(650px, calc(100dvh - 32px));
    max-height: calc(100dvh - 32px);
    padding: clamp(22px, 4vw, 42px);
}

.details-modal-content {
    width: min(100%, 800px);
}

@keyframes modalAppear {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.99);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 30px;
}

.modal-header h2,
.confirm-content h2 {
    margin: 0 0 10px;
    font-size: clamp(22px, 3vw, 29px);
    overflow-wrap: anywhere;
}

.close-button {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-light);
    color: var(--text);
    font-size: 27px;
    line-height: 1;
}

.close-button:hover {
    background: #303b4d;
}

#eventForm {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#eventForm label {
    margin-top: 10px;
    color: #dce3ed;
    font-size: 14px;
    font-weight: 700;
}

#eventForm input,
#eventForm textarea {
    width: 100%;
    padding: 14px;
    color: var(--text);
    background: #0c1119;
    border: 1px solid var(--border);
    border-radius: 9px;
}

#eventForm input {
    min-height: 48px;
    color-scheme: dark;
}

#eventForm textarea {
    resize: vertical;
    min-height: 100px;
}

#eventForm input:focus,
#eventForm textarea:focus {
    outline: none;
    border-color: var(--blue);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.form-row > div {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modal-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 28px;
}

.modal-actions button {
    min-height: 44px;
}

.form-error {
    color: var(--red);
    font-size: 14px;
    line-height: 1.5;
}

.eyebrow {
    display: block;
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1.5px;
}

.details-status {
    margin-bottom: 20px;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.detail-box {
    min-width: 0;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #0e141d;
}

.detail-box > span {
    display: block;
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 13px;
}

.detail-box strong {
    display: block;
    overflow-wrap: anywhere;
    line-height: 1.5;
}

.detail-box p {
    margin: 0;
    color: #dce3ed;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.action-spacer {
    flex: 1;
}

.confirm-modal {
    z-index: 1100;
}

.confirm-content {
    width: min(100%, 440px);
}

.confirm-content p {
    color: var(--muted);
    line-height: 1.5;
}

.confirm-content .modal-actions {
    justify-content: flex-end;
}

@media (max-width: 1000px) {
    .events-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 600px) {
    .topbar {
        align-items: stretch;
        flex-direction: column;
        padding: 20px 5%;
    }

    .topbar .add-button {
        width: 100%;
    }

    .container {
        width: 90%;
        margin: 24px auto;
    }

    .statistics {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-bottom: 30px;
    }

    .stat-card {
        padding: 20px;
    }

    .events-grid {
        grid-template-columns: 1fr;
    }

    .section-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .modal {
        padding: 8px;
    }

    .modal-content,
    .form-modal-content {
        max-height: calc(100dvh - 16px);
        min-height: 0;
        padding: 22px 17px;
        border-radius: 14px;
    }

    .form-row,
    .details-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .modal-actions {
        gap: 9px;
    }

    .modal-actions button {
        flex: 1 1 auto;
    }

    .details-actions .delete-button {
        flex-basis: 100%;
    }

    .action-spacer {
        display: none;
    }
}
