* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: #f5f5f5;
    color: #222;
}

.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* =========================
   HEADER
========================= */

header {
    margin-bottom: 30px;
}

header h1 {
    margin: 0 0 8px;
    font-size: 32px;
}

header p {
    margin: 0;
    color: #666;
}

/* =========================
   TOP BAR
========================= */

.top-bar {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 20px;

    background: white;
    border: 1px solid #ddd;
    border-radius: 10px;

    padding: 20px;
    margin-bottom: 25px;
}

.top-bar label {
    display: block;
    margin-bottom: 7px;

    font-size: 14px;
    font-weight: 600;
}

.threshold-input {
    display: flex;
    align-items: center;
    gap: 8px;
}

.threshold-input input {
    width: 80px;
}

/* =========================
   INPUTS
========================= */

input {
    width: 100%;

    padding: 10px 12px;

    border: 1px solid #ccc;
    border-radius: 6px;

    font-size: 15px;

    outline: none;
}

input:focus {
    border-color: #333;
}

/* =========================
   BUTTONS
========================= */

button {
    border: none;
    border-radius: 6px;

    padding: 9px 12px;

    font-size: 14px;

    cursor: pointer;
}

.primary-btn {
    background: #222;
    color: white;
}

.primary-btn:hover {
    background: #000;
}

.secondary-btn {
    background: #eee;
    color: #222;
}

.secondary-btn:hover {
    background: #ddd;
}

.present-btn {
    background: #198754;
    color: white;
}

.present-btn:hover {
    background: #146c43;
}

.absent-btn {
    background: #dc3545;
    color: white;
}

.absent-btn:hover {
    background: #bb2d3b;
}

.delete-btn {
    background: transparent;
    color: #dc3545;

    border: 1px solid #dc3545;
}

.delete-btn:hover {
    background: #dc3545;
    color: white;
}

/* =========================
   SUBJECT GRID
========================= */

#subjectsContainer {
    display: grid;

    grid-template-columns: repeat(3, minmax(0, 1fr));

    gap: 15px;
}

/* =========================
   SUBJECT CARD
========================= */

.subject-card {
    background: white;

    border: 1px solid #ddd;
    border-radius: 10px;

    padding: 18px;

    margin: 0;

    min-width: 0;
}

/* =========================
   SUBJECT HEADER
========================= */

.subject-header {
    display: block;

    margin-bottom: 14px;
}

.subject-header h2 {
    margin: 0 0 8px;

    font-size: 19px;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attendance-percentage {
    font-size: 28px;
    font-weight: bold;
}

/* =========================
   ATTENDANCE DETAILS
========================= */

.attendance-details {
    color: #666;

    font-size: 14px;

    margin-bottom: 12px;
}

/* =========================
   PROGRESS BAR
========================= */

.progress-container {
    width: 100%;

    height: 7px;

    background: #eee;

    border-radius: 10px;

    overflow: hidden;

    margin-bottom: 15px;
}

.progress-bar {
    height: 100%;

    background: #198754;

    transition: width 0.2s;
}

.progress-bar.warning {
    background: #f0ad4e;
}

.progress-bar.danger {
    background: #dc3545;
}

/* =========================
   INFORMATION BOXES
========================= */

.subject-info {
    display: grid;

    grid-template-columns: 1fr 1fr;

    gap: 8px;

    margin-bottom: 15px;
}

.info-box {
    background: #f7f7f7;

    border-radius: 7px;

    padding: 9px;
}

.info-label {
    font-size: 11px;

    color: #666;

    margin-bottom: 3px;
}

.info-value {
    font-size: 14px;

    font-weight: bold;
}

/* =========================
   SUBJECT ACTIONS
========================= */

.subject-actions {
    display: grid;

    grid-template-columns: 1fr 1fr;

    gap: 7px;
}

.subject-actions button {
    width: 100%;
}

/* Make Edit and Delete span the full card width */

.subject-actions .secondary-btn,
.subject-actions .delete-btn {
    grid-column: span 2;
}

/* =========================
   EMPTY STATE
========================= */

.empty-state {
    text-align: center;

    background: white;

    border: 1px dashed #ccc;

    border-radius: 10px;

    padding: 50px 20px;
}

.empty-state h2 {
    margin-bottom: 8px;
}

.empty-state p {
    margin: 0;

    color: #777;
}

/* =========================
   MODAL
========================= */

.modal {
    position: fixed;

    inset: 0;

    background: rgba(0, 0, 0, 0.45);

    display: flex;

    justify-content: center;
    align-items: center;

    padding: 20px;

    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    width: 100%;

    max-width: 450px;

    background: white;

    border-radius: 10px;

    padding: 25px;
}

.modal-content h2 {
    margin-top: 0;

    margin-bottom: 20px;
}

.modal-content label {
    display: block;

    margin-top: 15px;
    margin-bottom: 6px;

    font-size: 14px;
    font-weight: 600;
}

.modal-buttons {
    display: flex;

    justify-content: flex-end;

    gap: 8px;

    margin-top: 25px;
}

.error {
    color: #dc3545;

    font-size: 14px;

    margin-top: 12px;
}

/* =========================
   TABLET
========================= */

@media (max-width: 850px) {

    .container {
        padding: 30px 15px;
    }

    #subjectsContainer {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* =========================
   MOBILE
========================= */

@media (max-width: 550px) {

    .container {
        padding: 25px 12px;
    }

    header h1 {
        font-size: 26px;
    }

    .top-bar {
        align-items: stretch;

        flex-direction: column;
    }

    #subjectsContainer {
        grid-template-columns: 1fr;
    }

    .subject-card {
        padding: 18px;
    }

    .subject-header {
        display: flex;

        align-items: center;
        justify-content: space-between;

        gap: 10px;
    }

    .subject-header h2 {
        margin: 0;
    }

    .attendance-percentage {
        font-size: 24px;
    }
}