/* General Styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    background-color: #f0f2f5;
    color: #333;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header */
header {
    background-color: #fff;
    padding: 1rem 0;
    border-bottom: 1px solid #e0e0e0;
    margin-bottom: 2rem;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo a {
    font-size: 1.5rem;
    font-weight: bold;
    color: #333;
    text-decoration: none;
}

nav ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

nav ul li {
    display: inline-block;
    margin-left: 1.5rem;
}

nav a {
    text-decoration: none;
    color: #555;
    font-weight: 500;
}

nav a:hover {
    color: #007bff;
}

/* Main Content */
main.container {
    background-color: #fff;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    min-height: calc(100vh - 150px);
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 0;
    color: #888;
    font-size: 0.9rem;
}

/* Forms */
.form-container, .login-container {
    max-width: 500px;
    margin: 2rem auto;
    padding: 2rem;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

textarea {
    resize: vertical;
    min-height: 120px;
}

button[type="submit"], .btn {
    display: inline-block;
    width: 100%;
    padding: 0.75rem;
    border: none;
    border-radius: 4px;
    color: #fff;
    background-color: #007bff;
    cursor: pointer;
    font-size: 1rem;
    text-align: center;
    text-decoration: none;
}

button[type="submit"]:hover, .btn:hover {
    background-color: #0056b3;
}

.btn-danger {
    background-color: #dc3545;
}

.btn-danger:hover {
    background-color: #c82333;
}

.btn-success {
    background-color: #28a745;
}

.btn-success:hover {
    background-color: #218838;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1.5rem;
}

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
}

th {
    background-color: #f8f9fa;
    font-weight: 600;
}

/* Messages */
.message {
    padding: 1rem;
    margin-bottom: 1.5rem;
    border-radius: 4px;
    border: 1px solid transparent;
}

.success {
    color: #155724;
    background-color: #d4edda;
    border-color: #c3e6cb;
}

.error {
    color: #721c24;
    background-color: #f8d7da;
    border-color: #f5c6cb;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 1rem;
    transform: translateX(-50%);
    background: rgba(20, 20, 20, 0.92);
    color: #fff;
    padding: 0.75rem 1rem;
    border-radius: 999px;
    font-size: 0.95rem;
    line-height: 1.2;
    box-shadow: 0 8px 24px rgba(0,0,0,0.22);
    z-index: 9999;
    max-width: calc(100vw - 2rem);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.toast.error {
    background: rgba(220, 53, 69, 0.95);
    border: 0;
    color: #fff;
}

/* Homework Specific */
.homework-item {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: background-color 0.3s;
    display: grid;
    grid-template-areas:
        "content content"
        "details actions";
    grid-template-columns: 1fr auto;
    gap: 1rem;
}

.homework-content { grid-area: content; }
.homework-content strong { display: block; font-size: 1.05rem; line-height: 1.3; }
.homework-content p { margin: 0.5rem 0 0; line-height: 1.6; word-break: break-word; }
.file-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 999px;
    background-color: #eef5ff;
    color: #0b5ed7;
    text-decoration: none;
    font-weight: 600;
}
.file-link:hover { background-color: #dbeaff; }
.homework-details { grid-area: details; display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; }
.item-actions { grid-area: actions; display: flex; gap: 0.5rem; align-self: end; }

.detail-item { display: flex; align-items: center; gap: 0.5rem; }
.detail-item label { margin-bottom: 0; }
.detail-item select { min-width: 8.5rem; }

.homework-item.finished { background-color: #f0fff0; }
.homework-item.optional { border-left: 5px solid #17a2b8; }
.homework-item.must-not-finished { border-left: 5px solid #dc3545; }

.header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.date-filter-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.date-filter-form input[type="date"] {
    width: auto;
}

.date-filter-form label {
    margin-bottom: 0;
}

.header-actions .btn {
    width: auto;
}

.item-actions .btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    width: auto;
}

/* Action Buttons & Responsive Table */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 0;
    align-items: stretch;
}

.action-buttons .btn {
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    padding: 0.5rem 0.75rem;
}
.action-buttons .btn + .btn {
    margin-top: calc((1rem + (2 * 0.5rem)) / 2);
}

.btn-primary {
    background-color: #007bff;
}
.btn-primary:hover {
    background-color: #0056b3;
}

.btn-secondary {
    background-color: #6c757d;
}
.btn-secondary:hover {
    background-color: #5a6268;
}

@media screen and (max-width: 768px) {
    main.container {
        padding: 1rem;
        border-radius: 0;
    }

    header {
        margin-bottom: 1rem;
    }

    .form-container, .login-container {
        max-width: none;
        width: 100%;
        margin: 1rem auto;
        padding: 1rem;
        box-sizing: border-box;
    }

    .header-actions {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
    }

    .date-filter-form {
        width: auto;
        flex: 1;
        flex-wrap: nowrap;
        justify-content: flex-start;
    }

    .date-filter-form input[type="date"] {
        width: auto;
        flex: 1;
        min-width: 120px;
    }

    .date-filter-form label {
        width: auto;
        white-space: nowrap;
    }

    .header-actions .btn {
        flex: none;
        white-space: nowrap;
    }

    nav ul {
        display: none; /* Example: Hide nav on mobile for simplicity, could be a burger menu */
    }

    table thead {
        display: none;
    }

    table tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid #e0e0e0;
        border-radius: 8px;
        padding: 1rem;
        box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    }

    table td {
        display: block;
        text-align: right;
        border-bottom: 1px solid #eee;
        padding: 0.75rem;
        padding-left: 50%;
        position: relative;
    }

    table td:last-child {
        border-bottom: 0;
    }

    table td::before {
        content: attr(data-label);
        position: absolute;
        left: 0.75rem;
        width: calc(50% - 1.5rem);
        text-align: left;
        font-weight: 600;
        color: #333;
    }

    .action-buttons {
        flex-direction: row;
        justify-content: flex-end;
        gap: 0.75rem;
    }

    .action-buttons .btn {
        width: auto;
        padding: 0.5rem 1rem;
    }
    .action-buttons .btn + .btn {
        margin-top: 0;
        margin-left: 0.75rem;
    }

    .homework-item {
        grid-template-areas:
            "content"
            "details"
            "actions";
        grid-template-columns: 1fr;
        padding: 1rem;
    }

    .item-actions {
        justify-self: stretch;
        width: 100%;
        display: flex;
        flex-direction: row;
        gap: 0.5rem;
    }

    .item-actions .btn {
        flex: 1;
        width: auto;
        padding: 0.6rem 0.75rem;
        font-size: 0.95rem;
    }

    .homework-details {
        gap: 0.75rem;
    }

    .detail-item {
        width: 100%;
        justify-content: space-between;
    }

    .detail-item select {
        min-width: 0;
        width: 12rem;
        max-width: 70%;
    }
}
