/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--gray-100);
    color: var(--gray-900);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

/* Header */
header {
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-top {
    max-width: 800px;
    margin: 0 auto;
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.logo {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
    white-space: nowrap;
}

.classroom-info {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-width: 0;
}

.classroom-name {
    font-size: 0.875rem;
    color: var(--gray-700);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.settings-link {
    font-size: 0.85rem;
    text-decoration: none;
    opacity: 0.5;
    transition: opacity 0.15s ease;
}

.settings-link:hover {
    opacity: 1;
}

.drive-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: #4285f4;
    color: white;
    border-radius: 0.375rem;
    text-decoration: none;
    font-size: 1rem;
    transition: background 0.15s ease;
}

.drive-btn:hover {
    background: #3367d6;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.parent-name {
    color: var(--gray-500);
    font-size: 0.75rem;
    display: none;
}

@media (min-width: 480px) {
    .parent-name {
        display: inline;
    }
}

.btn-logout {
    color: var(--gray-500);
    text-decoration: none;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    background: var(--gray-100);
    border-radius: 0.25rem;
}

.btn-logout:hover {
    color: var(--danger);
    background: #fef2f2;
}

/* Language toggle */
.lang-toggle {
    display: flex;
    align-items: center;
}

.lang-btn {
    background: var(--gray-100);
    color: var(--gray-700);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 500;
    transition: background 0.2s;
}

.lang-btn:hover {
    background: var(--gray-200);
}

/* Main Navigation */
.main-nav {
    max-width: 800px;
    margin: 0 auto;
    padding: 0;
    display: flex;
    justify-content: space-around;
    border-top: 1px solid var(--gray-100);
}

.nav-link {
    flex: 1;
    padding: 0.75rem 0.5rem;
    color: var(--gray-500);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    text-align: center;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.nav-link:hover {
    color: var(--gray-900);
}

.nav-link.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Main content */
main {
    flex: 1;
    max-width: 800px;
    margin: 0 auto;
    padding: 0.75rem;
    width: 100%;
}

/* Footer */
footer {
    background: white;
    padding: 0.75rem;
    text-align: center;
    color: var(--gray-500);
    font-size: 0.7rem;
}

/* ================== */
/* HOMEPAGE STYLES */
/* ================== */

.homepage {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem 1rem;
    min-height: 80vh;
}

.homepage-hero {
    text-align: center;
    margin-bottom: 2rem;
}

.homepage-hero h1 {
    font-size: 1.75rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.homepage-hero p {
    color: var(--gray-500);
    font-size: 1rem;
}

.create-classroom-form {
    width: 100%;
    max-width: 400px;
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.create-classroom-form h2 {
    font-size: 1.25rem;
    margin-bottom: 1.25rem;
    text-align: center;
}

/* ================== */
/* LOGIN STYLES */
/* ================== */

.login-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem 1rem;
    min-height: 70vh;
}

.login-box {
    width: 100%;
    max-width: 400px;
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.login-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-header h1 {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.login-header .school-name {
    color: var(--gray-500);
    font-size: 0.875rem;
}

.login-form .btn-primary {
    width: 100%;
    margin-top: 0.5rem;
}

.error-message {
    background: #fef2f2;
    color: var(--danger);
    padding: 0.75rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    text-align: center;
    font-size: 0.875rem;
}

/* Login footer and manager link */
.login-footer {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--gray-200);
    text-align: center;
}

.manager-login-link {
    color: var(--gray-500);
    font-size: 0.8rem;
    text-decoration: none;
}

.manager-login-link:hover {
    color: var(--primary);
    text-decoration: underline;
}

/* Info box */
.info-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: #1e40af;
}

/* ================== */
/* PAGE LAYOUT */
/* ================== */

.page {
    padding-bottom: 1rem;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    gap: 0.5rem;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
}

/* Filter Bar */
.filter-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.filter-select {
    flex: 1;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--gray-300);
    border-radius: 0.5rem;
    font-size: 0.8rem;
    background: white;
    cursor: pointer;
}

.filter-past {
    flex: 0 0 auto;
    width: auto;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary);
}

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

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.25rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: white;
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
    padding: 0.75rem 1.25rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-secondary:hover {
    background: var(--gray-50);
}

.btn-add {
    background: var(--success);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.8rem;
    white-space: nowrap;
}

.btn-add:hover {
    background: #059669;
}

/* ================== */
/* FORM STYLES */
/* ================== */

.form-page {
    background: white;
    border-radius: 0.75rem;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.form-page h1 {
    font-size: 1.25rem;
    margin-bottom: 1.25rem;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 500;
    color: var(--gray-700);
    font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.7rem;
    border: 1px solid var(--gray-300);
    border-radius: 0.5rem;
    font-size: 1rem;
    background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 70px;
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--gray-500);
}

.form-help {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* Settings page URL box */
.url-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
}

.url-box code {
    flex: 1;
    font-size: 0.8rem;
    color: var(--gray-700);
    word-break: break-all;
    font-family: monospace;
}

.copy-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.4rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease;
}

.copy-btn:hover {
    background: var(--primary-dark);
}

.classroom-id-display {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--gray-200);
}

.form-group input[type="file"] {
    padding: 0.5rem;
    font-size: 0.875rem;
}

/* Input with button (password generate) */
.input-with-button {
    display: flex;
    gap: 0.5rem;
}

.input-with-button input {
    flex: 1;
}

.btn-generate {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.btn-generate:hover {
    background: var(--gray-200);
    border-color: var(--gray-400);
}

/* Form section title */
.form-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--gray-200);
}

.form-section-title:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
    flex-direction: column-reverse;
}

.form-actions .btn-secondary,
.form-actions .btn-primary {
    width: 100%;
}

@media (min-width: 480px) {
    .form-actions {
        flex-direction: row;
        justify-content: flex-end;
    }
    .form-actions .btn-secondary,
    .form-actions .btn-primary {
        width: auto;
    }
}

/* Checkbox grid for subjects */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    font-weight: normal;
    font-size: 0.9rem;
}

.checkbox-item input[type="checkbox"] {
    width: auto;
    margin: 0;
}

/* ================== */
/* SIMPLE LIST VIEW */
/* ================== */

.simple-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.simple-item {
    background: white;
    border-radius: 0.375rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.item-link {
    display: block;
    padding: 0.6rem 0.75rem;
    text-decoration: none;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
}

.item-link:active {
    background: var(--gray-50);
}

.item-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}

.item-row-meta {
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--gray-500);
}

.item-date {
    font-weight: 500;
}

.item-date.overdue {
    color: var(--danger);
}

.item-days {
    color: var(--primary);
    font-weight: 500;
}

.item-days.overdue,
.item-days.passed {
    color: var(--gray-500);
}

.item-files {
    color: var(--gray-500);
    font-size: 0.75rem;
}

.item-by {
    margin-left: auto;
}

body.rtl .item-by {
    margin-left: 0;
    margin-right: auto;
}

/* ================== */
/* DETAIL PAGE */
/* ================== */

.detail-page {
    padding-bottom: 1rem;
}

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

.back-link {
    color: var(--gray-500);
    text-decoration: none;
    font-size: 0.9rem;
}

.back-link:hover {
    color: var(--primary);
}

.btn-edit {
    background: var(--gray-100);
    color: var(--gray-700);
    padding: 0.4rem 0.75rem;
    border-radius: 0.375rem;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
}

.btn-edit:hover {
    background: var(--gray-200);
}

/* Detail actions (edit + delete) */
.detail-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.delete-form {
    display: inline;
    margin: 0;
}

.btn-delete {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
    padding: 0.4rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-delete:hover {
    background: #fee2e2;
    border-color: #fca5a5;
}

.detail-card {
    background: white;
    border-radius: 0.75rem;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.detail-top {
    margin-bottom: 0.75rem;
}

.detail-top .item-subject {
    margin-bottom: 0.35rem;
    display: inline-block;
}

.detail-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 0.25rem;
}

.detail-pages {
    color: var(--primary);
    font-weight: 500;
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

.detail-date {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem;
    background: var(--gray-50);
    border-radius: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.date-label {
    color: var(--gray-500);
}

.date-value {
    font-weight: 500;
}

.date-value.overdue {
    color: var(--danger);
}

.days-badge {
    color: var(--primary);
    font-weight: 500;
}

.days-badge.overdue,
.days-badge.passed {
    color: var(--gray-500);
}

.detail-section {
    margin-bottom: 0.75rem;
}

.section-title {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--gray-500);
    margin-bottom: 0.35rem;
}

.section-content {
    font-size: 0.95rem;
    line-height: 1.5;
    white-space: pre-wrap;
}

.detail-images,
.detail-files {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.detail-image {
    display: block;
    border-radius: 0.5rem;
    overflow: hidden;
    border: 1px solid var(--gray-200);
}

.detail-image img {
    max-width: 100%;
    max-height: 300px;
    display: block;
}

.detail-file {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 0.5rem;
    text-decoration: none;
    color: var(--gray-700);
    transition: background 0.15s ease;
}

.detail-file:hover {
    background: var(--gray-100);
}

.detail-file .file-icon {
    font-size: 1.5rem;
}

.detail-file .file-name {
    font-size: 0.9rem;
    font-weight: 500;
    word-break: break-word;
}

.detail-meta {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--gray-100);
    font-size: 0.75rem;
    color: var(--gray-500);
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

/* Existing files in edit form */
.existing-images,
.existing-files {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.existing-image {
    width: 80px;
    height: 80px;
    border-radius: 0.375rem;
    overflow: hidden;
    border: 1px solid var(--gray-200);
}

.existing-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.existing-file {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 0.75rem;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 0.375rem;
    text-decoration: none;
    color: var(--gray-700);
    font-size: 0.8rem;
}

.existing-file:hover {
    background: var(--gray-100);
}

.existing-file .file-icon {
    font-size: 1.1rem;
}

.existing-file .file-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* File edit with delete option */
.existing-files-edit {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.file-item-edit {
    position: relative;
    display: inline-block;
}

.file-delete-checkbox {
    position: absolute;
    top: -6px;
    right: -6px;
    z-index: 10;
    cursor: pointer;
}

.file-delete-checkbox input[type="checkbox"] {
    display: none;
}

.file-delete-checkbox .delete-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: var(--gray-100);
    border: 1px solid var(--gray-300);
    border-radius: 50%;
    color: var(--gray-500);
    font-size: 12px;
    font-weight: bold;
    transition: all 0.15s ease;
}

.file-delete-checkbox:hover .delete-mark {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #dc2626;
}

.file-delete-checkbox input[type="checkbox"]:checked + .delete-mark {
    background: #dc2626;
    border-color: #dc2626;
    color: white;
}

.file-item-edit:has(input[type="checkbox"]:checked) .existing-image,
.file-item-edit:has(input[type="checkbox"]:checked) .existing-file {
    opacity: 0.4;
}

.delete-hint {
    display: block;
    margin-top: 0.5rem;
    color: var(--gray-500);
    font-size: 0.75rem;
}

/* Teacher header with edit link */
.teacher-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.25rem;
}

.edit-link {
    color: var(--gray-400);
    text-decoration: none;
    font-size: 0.75rem;
}

.edit-link:hover {
    color: var(--primary);
}

/* ================== */
/* LIST VIEW STYLES (legacy) */
/* ================== */

.item-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.item {
    background: white;
    border-radius: 0.5rem;
    padding: 0.75rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Homework & Test items */
.item-main {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.4rem;
}

.item-subject {
    padding: 0.15rem 0.5rem;
    border-radius: 0.75rem;
    font-size: 0.7rem;
    font-weight: 500;
}

.item-title {
    font-weight: 500;
    font-size: 0.95rem;
}

.item-pages {
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 500;
}

.item-desc {
    color: var(--gray-500);
    font-size: 0.8rem;
    margin-bottom: 0.4rem;
    line-height: 1.4;
}

.item-due {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-bottom: 0.4rem;
}

.item-due.overdue {
    color: var(--danger);
    font-weight: 500;
}

/* Test-specific styles */
.test-item.big-test {
    border-left: 3px solid var(--warning);
}

.test-item.passed {
    opacity: 0.6;
}

.test-type-badge {
    padding: 0.15rem 0.5rem;
    border-radius: 0.75rem;
    font-size: 0.7rem;
    font-weight: 500;
}

.type-small {
    background: var(--gray-100);
    color: var(--gray-700);
}

.type-big {
    background: #fef3c7;
    color: #92400e;
}

/* Event type badges */
.event-type-badge {
    padding: 0.15rem 0.5rem;
    border-radius: 0.75rem;
    font-size: 0.7rem;
    font-weight: 500;
}

.type-parent_meeting {
    background: #dbeafe;
    color: #1e40af;
}

.type-fathers_sons {
    background: #dcfce7;
    color: #166534;
}

.type-conference {
    background: #f3e8ff;
    color: #6b21a8;
}

.type-trip {
    background: #fef3c7;
    color: #92400e;
}

.type-party {
    background: #fce7f3;
    color: #9d174d;
}

.type-performance {
    background: #ffedd5;
    color: #c2410c;
}

.type-other {
    background: var(--gray-100);
    color: var(--gray-700);
}

.item-time {
    color: var(--gray-500);
    font-size: 0.75rem;
}

.time-value {
    color: var(--gray-600);
    font-size: 0.9rem;
    margin-left: 0.5rem;
}

body.rtl .time-value {
    margin-left: 0;
    margin-right: 0.5rem;
}

.test-date-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.test-date {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--gray-700);
}

.days-badge {
    font-size: 0.75rem;
    color: var(--primary);
    font-weight: 500;
}

.days-badge.passed {
    color: var(--gray-500);
}

.item-study {
    font-size: 0.8rem;
    color: var(--gray-600);
    background: var(--gray-50);
    padding: 0.5rem;
    border-radius: 0.25rem;
    margin-bottom: 0.4rem;
}

.item-study strong {
    color: var(--gray-700);
}

/* Item images gallery */
.item-images {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0.5rem 0;
}

.thumb {
    display: block;
    width: 60px;
    height: 60px;
    border-radius: 0.25rem;
    overflow: hidden;
    border: 1px solid var(--gray-200);
}

.thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.item-meta {
    font-size: 0.7rem;
    color: var(--gray-500);
    border-top: 1px solid var(--gray-100);
    padding-top: 0.4rem;
    margin-top: 0.25rem;
}

/* Subject colors */
.subject-math { background: #dbeafe; color: #1e40af; }
.subject-english { background: #fce7f3; color: #9d174d; }
.subject-science { background: #d1fae5; color: #065f46; }
.subject-history { background: #fef3c7; color: #92400e; }
.subject-hebrew { background: #e0e7ff; color: #3730a3; }
.subject-bible { background: #f3e8ff; color: #6b21a8; }
.subject-torah { background: #fdf4ff; color: #86198f; }
.subject-geography { background: #cffafe; color: #0e7490; }
.subject-other { background: var(--gray-200); color: var(--gray-700); }

/* ================== */
/* TEACHER LIST */
/* ================== */

.teacher-list .teacher-item {
    padding: 0.75rem;
}

.teacher-item.main-teacher {
    border-left: 3px solid var(--primary);
}

.teacher-main {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.teacher-role {
    padding: 0.15rem 0.5rem;
    border-radius: 0.75rem;
    font-size: 0.7rem;
    font-weight: 500;
}

.role-main {
    background: #e0e7ff;
    color: #3730a3;
}

.role-subject {
    background: var(--gray-100);
    color: var(--gray-700);
}

.teacher-name {
    font-weight: 500;
    font-size: 0.95rem;
}

.teacher-subjects {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-bottom: 0.5rem;
}

.subj-tag {
    background: var(--gray-100);
    color: var(--gray-600);
    padding: 0.15rem 0.4rem;
    border-radius: 0.25rem;
    font-size: 0.7rem;
}

/* Teacher Contact Section */
.teacher-contact {
    background: var(--gray-50);
    border-radius: 0.5rem;
    padding: 0.6rem;
}

.contact-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.phone-num {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--gray-700);
}

.contact-methods {
    display: flex;
    gap: 0.4rem;
}

.contact-badge {
    display: flex;
    align-items: center;
    gap: 0.15rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 600;
    transition: transform 0.15s ease;
}

.contact-badge:active {
    transform: scale(0.95);
}

.contact-badge.whatsapp {
    background: #25D366;
    color: white;
}

.contact-badge.sms {
    background: #007AFF;
    color: white;
}

.contact-badge.phone {
    background: var(--success);
    color: white;
}

.badge-icon {
    font-size: 0.7rem;
}

.badge-check {
    color: #90EE90;
    font-weight: bold;
    font-size: 0.75rem;
}

.contact-badge.whatsapp .badge-check {
    color: #c8ffd4;
}

.contact-badge.sms .badge-check,
.contact-badge.phone .badge-check {
    color: #b8e6ff;
}

.contact-hours {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--gray-200);
    font-size: 0.8rem;
    color: var(--gray-600);
}

.hours-icon {
    font-size: 0.85rem;
}

.hours-text {
    font-weight: 500;
}

/* Contact methods in form */
.contact-methods.checkbox-grid {
    grid-template-columns: repeat(3, 1fr);
}

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

.empty {
    text-align: center;
    padding: 2.5rem 1rem;
    background: white;
    border-radius: 0.75rem;
}

.empty p {
    margin-bottom: 0.75rem;
    color: var(--gray-500);
    font-size: 0.95rem;
}

.empty .btn-primary {
    margin-top: 0.5rem;
}

/* ================== */
/* CALENDAR */
/* ================== */

.calendar-page {
    padding-bottom: 1rem;
}

/* Calendar Header */
.cal-header {
    background: white;
    border-radius: 0.75rem;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.cal-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.cal-nav-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
    border-radius: 50%;
    text-decoration: none;
    color: var(--gray-700);
    font-size: 1.25rem;
    transition: background 0.2s;
}

.cal-nav-btn:hover {
    background: var(--gray-200);
}

.cal-nav-btn .arrow {
    line-height: 1;
}

.cal-title {
    text-align: center;
    flex: 1;
}

.cal-day-name {
    display: block;
    font-size: 0.8rem;
    color: var(--gray-500);
}

.cal-date-display {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-900);
}

.cal-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.cal-today-btn {
    padding: 0.4rem 0.75rem;
    background: var(--primary);
    color: white;
    border-radius: 0.375rem;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
}

.cal-view-toggle {
    display: flex;
    background: var(--gray-100);
    border-radius: 0.5rem;
    padding: 0.2rem;
}

.view-btn {
    padding: 0.35rem 0.6rem;
    color: var(--gray-600);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 0.375rem;
    transition: all 0.2s;
}

.view-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Day View */
.cal-day-view {
    background: white;
    border-radius: 0.75rem;
    padding: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.cal-events-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.cal-event {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--gray-50);
    border-radius: 0.5rem;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s;
}

.cal-event:active {
    background: var(--gray-100);
}

.cal-event.test.big {
    border-left: 3px solid var(--warning);
}

body.rtl .cal-event.test.big {
    border-left: none;
    border-right: 3px solid var(--warning);
}

.event-badge {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    font-size: 1.25rem;
}

.event-badge.homework {
    background: #dbeafe;
}

.event-badge.test {
    background: #fef3c7;
}

.event-badge.event {
    background: #f3e8ff;
}

.event-time,
.event-location {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.event-content {
    flex: 1;
    min-width: 0;
}

.event-subject {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 0.5rem;
    font-size: 0.65rem;
    font-weight: 500;
    margin-bottom: 0.2rem;
}

.event-title {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--gray-900);
}

.event-pages {
    font-size: 0.75rem;
    color: var(--primary);
    margin-top: 0.15rem;
}

.event-type-badge {
    padding: 0.25rem 0.5rem;
    background: var(--gray-200);
    border-radius: 0.375rem;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--gray-600);
}

.event-type-badge.type-big {
    background: #fef3c7;
    color: #92400e;
}

.cal-empty {
    text-align: center;
    padding: 2rem;
    color: var(--gray-500);
}

.empty-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

/* Week View */
.cal-week-view {
    background: white;
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.week-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.week-day-header {
    padding: 0.5rem 0.25rem;
    text-align: center;
}

.week-day-header.today {
    background: var(--primary);
    color: white;
}

.week-day-header .day-name {
    display: block;
    font-size: 0.65rem;
    font-weight: 500;
    opacity: 0.8;
}

.week-day-header .day-num {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
}

.week-body {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    min-height: 200px;
}

.week-day {
    padding: 0.35rem;
    border-right: 1px solid var(--gray-100);
    min-height: 100px;
    cursor: pointer;
    transition: background 0.2s;
}

.week-day:last-child {
    border-right: none;
}

.week-day:active {
    background: var(--gray-50);
}

.week-day.today {
    background: #eff6ff;
}

.week-event {
    padding: 0.25rem;
    margin-bottom: 0.2rem;
    border-radius: 0.25rem;
    font-size: 0.6rem;
    line-height: 1.2;
    overflow: hidden;
}

.week-event.homework {
    background: #dbeafe;
    color: #1e40af;
}

.week-event.test {
    background: #fef3c7;
    color: #92400e;
}

.week-event.test.big {
    background: #fde68a;
    font-weight: 600;
}

.week-event.event {
    background: #f3e8ff;
    color: #6b21a8;
}

.we-subject {
    display: block;
    font-weight: 600;
}

.we-title {
    display: block;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.week-day-empty {
    height: 100%;
}

/* Month View */
.cal-month-view {
    background: white;
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.month-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.month-day-name {
    padding: 0.5rem 0.25rem;
    text-align: center;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--gray-600);
}

.month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.month-day {
    min-height: 60px;
    padding: 0.25rem;
    border-right: 1px solid var(--gray-100);
    border-bottom: 1px solid var(--gray-100);
    cursor: pointer;
    transition: background 0.2s;
}

.month-day:nth-child(7n) {
    border-right: none;
}

.month-day:active {
    background: var(--gray-50);
}

.month-day.today {
    background: #eff6ff;
}

.month-day.today .md-num {
    background: var(--primary);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.month-day.other-month {
    opacity: 0.4;
}

.md-num {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.2rem;
}

.md-events {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.md-event {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.55rem;
    line-height: 1.2;
}

.md-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    flex-shrink: 0;
}

.md-event.homework .md-dot {
    background: #3b82f6;
}

.md-event.test .md-dot {
    background: #f59e0b;
}

.md-event.test.big .md-dot {
    background: #dc2626;
}

.md-event.event .md-dot {
    background: #9333ea;
}

.md-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--gray-600);
}

.md-more {
    font-size: 0.55rem;
    color: var(--gray-500);
    font-weight: 500;
}

/* ================== */
/* RTL SUPPORT */
/* ================== */

body.rtl {
    direction: rtl;
    text-align: right;
}

body.ltr {
    direction: ltr;
    text-align: left;
}

/* RTL border adjustments */
body.rtl .test-item.big-test,
body.rtl .teacher-item.main-teacher {
    border-left: none;
    border-right: 3px solid;
}

body.rtl .test-item.big-test {
    border-right-color: var(--warning);
}

body.rtl .teacher-item.main-teacher {
    border-right-color: var(--primary);
}

body.rtl .form-actions {
    flex-direction: column-reverse;
}

@media (min-width: 480px) {
    body.rtl .form-actions {
        flex-direction: row-reverse;
    }
    body.ltr .form-actions {
        flex-direction: row;
    }
}

/* ================== */
/* RESPONSIVE */
/* ================== */

@media (min-width: 640px) {
    main {
        padding: 1rem;
    }

    .page-title {
        font-size: 1.5rem;
    }

    .filter-select {
        width: auto;
        min-width: 200px;
    }

    .item {
        padding: 1rem;
    }

    .item-title {
        font-size: 1rem;
    }

    .thumb {
        width: 80px;
        height: 80px;
    }

    .checkbox-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ================== */
/* SITE FOOTER */
/* ================== */

.site-footer {
    margin-top: auto;
    padding: 1.5rem 1rem;
    text-align: center;
    background: #f8f9fa;
    border-top: 1px solid var(--gray-200);
    font-size: 0.85rem;
    color: var(--gray-500);
}

.site-footer a {
    color: var(--primary);
    text-decoration: none;
}

.site-footer a:hover {
    text-decoration: underline;
}
