* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 30px;
    background: #f5f7fb;
    font-family: Arial, Helvetica, sans-serif;
    color: #1f2937;
}

.container {
    max-width: 1200px;
    margin: auto;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 25px;
}

.page-title h1 {
    margin: 0 0 6px;
    font-size: 28px;
}

.page-title p {
    margin: 0;
    color: #6b7280;
}

.card {
    background: #ffffff;
    border-radius: 12px;
    padding: 22px;
    margin-bottom: 20px;
    box-shadow: 0 3px 15px rgba(0, 0, 0, .06);
}

.school-selector {
    display: flex;
    align-items: end;
    gap: 15px;
}

.form-group {
    flex: 1;
}

label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 7px;
}

input,
select {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #d1d5db;
    border-radius: 7px;
    font-size: 14px;
    background: #fff;
}

input:focus,
select:focus {
    outline: none;
    border-color: #2563eb;
}

button {
    border: none;
    cursor: pointer;
    border-radius: 7px;
    padding: 10px 15px;
    font-size: 14px;
    font-weight: 600;
}

.btn-primary {
    background: #2563eb;
    color: white;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-edit {
    background: #f3f4f6;
    color: #374151;
}

.btn-delete {
    background: #fee2e2;
    color: #b91c1c;
}

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 13px 12px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

th {
    font-size: 13px;
    color: #6b7280;
    background: #f9fafb;
}

td {
    font-size: 14px;
}

.period-number {
    font-weight: 700;
}

.badge {
    display: inline-block;
    padding: 5px 9px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-lesson {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-break {
    background: #fef3c7;
    color: #92400e;
}

.badge-lunch {
    background: #dcfce7;
    color: #166534;
}

.badge-study {
    background: #ede9fe;
    color: #6d28d9;
}

.actions {
    display: flex;
    gap: 7px;
}

.actions form {
    margin: 0;
}

.empty {
    text-align: center;
    padding: 45px 20px;
    color: #6b7280;
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
}

.modal.show {
    display: flex;
}

.modal-content {
    width: 100%;
    max-width: 550px;
    background: white;
    border-radius: 12px;
    padding: 25px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    margin: 0;
}

.close {
    font-size: 24px;
    cursor: pointer;
    color: #6b7280;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.full {
    grid-column: 1 / -1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
}

.btn-cancel {
    background: #f3f4f6;
    color: #374151;
}

.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    min-width: 280px;
    max-width: 400px;
    padding: 14px 18px;
    border-radius: 8px;
    color: white;
    box-shadow: 0 8px 25px rgba(0, 0, 0, .15);
    z-index: 2000;
    animation: slideIn .3s ease;
}

.toast-success {
    background: #16a34a;
}

.toast-error {
    background: #dc2626;
}


/* =========================================================
   SCHOOL SELECTOR + ADD PERIOD
========================================================= */

.school-selector-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.school-selector-form {
    display: flex;
    align-items: center;
    gap: 10px;
}

.school-selector-form label {
    margin: 0;
    white-space: nowrap;
}

.school-selector-form select {
    width: 300px;
}

.add-period-btn {
    flex-shrink: 0;
    margin-bottom: 0;
}

/* =========================================================
   BULK PERIOD MODAL
========================================================= */

.bulk-period-modal {
    align-items: flex-start;
    padding: 30px 20px;
    overflow-y: auto;
}


.bulk-period-modal-content {
    width: 100%;
    max-width: 1100px;
    max-height: calc(100vh - 60px);

    display: flex;
    flex-direction: column;

    margin: 0 auto;
}


/* =========================================================
   BULK PERIOD FORM
========================================================= */

#bulkPeriodForm {
    display: flex;
    flex-direction: column;

    min-height: 0;
}


/* =========================================================
   BULK PERIOD ROWS
========================================================= */

#bulkPeriodRows {
    overflow-y: auto;

    max-height: calc(100vh - 280px);

    padding-right: 8px;
}


/* =========================================================
   BULK PERIOD ROW
========================================================= */

.bulk-period-row {
    flex-shrink: 0;
}


/* =========================================================
   BULK MODAL FOOTER
========================================================= */

.bulk-period-modal-content
.modal-footer {
    flex-shrink: 0;
}


/* =========================================================
   ANIMATION
========================================================= */

@keyframes slideIn {

    from {
        opacity: 0;
        transform: translateX(30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }

}


/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width: 700px) {

    body {
        padding: 15px;
    }

    .page-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .school-selector {
        flex-direction: column;
        align-items: stretch;
    }

    .school-selector-row {
        flex-direction: column;
        align-items: stretch;
    }

    .school-selector-form {
        width: 100%;
    }

    .school-selector-form select {
        flex: 1;
        width: auto;
    }

    .add-period-btn {
        width: 100%;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .full {
        grid-column: auto;
    }

}