@import url('https://cdn.jsdelivr.net/gh/rastikerdar/vazir-font@v30.1.0/dist/font-face.css');

:root {
    --teal: #1F6F5C;
    --teal-dark: #14483C;
    --teal-light: #2E9E6F;
    --amber: #E8A33D;
    --amber-dark: #C9822A;
    --cream: #FAF7F0;
    --cream-2: #F1ECDF;
    --ink: #2B2B26;
    --danger: #D64545;
    --info: #4A7FBF;
    --card-radius: 18px;
    --shadow: 0 8px 24px rgba(31, 111, 92, 0.10);
    --shadow-lg: 0 16px 40px rgba(31, 111, 92, 0.18);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Vazir', Tahoma, sans-serif;
    background: var(--cream);
    color: var(--ink);
    direction: rtl;
}

a { color: inherit; text-decoration: none; }

/* ============ صفحات ورود/نصب ============ */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--teal) 0%, var(--teal-dark) 55%, #0E2E27 100%);
    background-size: 200% 200%;
    animation: gradientShift 12s ease infinite;
}
@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
.auth-card {
    background: #fff;
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    padding: 36px 30px;
    width: 100%;
    max-width: 400px;
    text-align: center;
}
.auth-logo { font-size: 48px; margin-bottom: 6px; }
.auth-card h1 { font-size: 20px; margin: 6px 0 2px; color: var(--teal-dark); }
.auth-subtitle { color: #8a8578; font-size: 14px; margin-bottom: 18px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; text-align: right; margin-top: 10px; }
.auth-form label { font-size: 13px; color: #6b6759; display: flex; flex-direction: column; gap: 6px; }

input, select, textarea {
    font-family: inherit;
    font-size: 15px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1.5px solid #E5E1D8;
    background: #fff;
    color: var(--ink);
    width: 100%;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--teal-light);
    box-shadow: 0 0 0 3px rgba(46,158,111,0.15);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 12px;
    border: none;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease;
}
.btn:active { transform: scale(0.97); }
.btn-block { width: 100%; }
.btn-primary { background: linear-gradient(135deg, var(--teal-light), var(--teal)); color: #fff; box-shadow: 0 6px 16px rgba(31,111,92,0.35); }
.btn-amber { background: linear-gradient(135deg, #F3B65C, var(--amber-dark)); color: #fff; box-shadow: 0 6px 16px rgba(201,130,42,0.35); }
.btn-danger { background: linear-gradient(135deg, #E86A6A, var(--danger)); color: #fff; }
.btn-outline { background: #fff; color: var(--teal); border: 1.5px solid var(--teal-light); }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.alert { padding: 12px 14px; border-radius: 12px; font-size: 14px; margin-bottom: 14px; text-align: right; }
.alert-success { background: #E4F5EC; color: #1E7A4C; }
.alert-error { background: #FBE7E7; color: #B23A3A; }
.alert-warning { background: #FDF1DC; color: #96650F; }
.alert-info { background: #E9F0FA; color: #2F5C96; }

/* ============ چارچوب اپ (بعد از ورود) ============ */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.app-header {
    background: linear-gradient(120deg, var(--teal-dark), var(--teal));
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    box-shadow: 0 4px 14px rgba(0,0,0,0.12);
    position: sticky;
    top: 0;
    z-index: 20;
}
.app-header .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; }
.app-header .brand .emoji { font-size: 24px; }
.app-header .user-chip {
    background: rgba(255,255,255,0.15);
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 13px;
    display: flex; align-items: center; gap: 8px;
}
.app-nav {
    display: flex;
    gap: 6px;
    padding: 10px 16px;
    background: #fff;
    overflow-x: auto;
    box-shadow: var(--shadow);
    position: sticky;
    top: 64px;
    z-index: 15;
}
.app-nav a {
    padding: 9px 16px;
    border-radius: 999px;
    font-size: 13.5px;
    font-weight: 700;
    color: #6b6759;
    white-space: nowrap;
}
.app-nav a.active, .app-nav a:hover { background: var(--cream-2); color: var(--teal-dark); }

.app-main { flex: 1; padding: 18px; max-width: 1100px; margin: 0 auto; width: 100%; }

.card {
    background: #fff;
    border-radius: var(--card-radius);
    box-shadow: var(--shadow);
    padding: 18px;
    margin-bottom: 16px;
}
.card h2 { margin: 0 0 14px; font-size: 17px; color: var(--teal-dark); }
.card h3 { margin: 0 0 10px; font-size: 15px; color: var(--teal-dark); }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.stat-card {
    border-radius: 16px;
    padding: 16px;
    color: #fff;
    box-shadow: var(--shadow);
}
.stat-card .num { font-size: 26px; font-weight: 800; }
.stat-card .lbl { font-size: 13px; opacity: .9; }
.stat-present { background: linear-gradient(135deg, #40B37F, var(--teal-light)); }
.stat-late { background: linear-gradient(135deg, #F3B65C, var(--amber)); }
.stat-excused { background: linear-gradient(135deg, #6FA0DA, var(--info)); }
.stat-unexcused { background: linear-gradient(135deg, #E88888, var(--danger)); }

/* ============ لیست دانش‌آموزان / ثبت حضور ============ */
.date-banner {
    background: linear-gradient(120deg, var(--amber-dark), var(--amber));
    color: #fff;
    border-radius: var(--card-radius);
    padding: 16px 18px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    box-shadow: var(--shadow);
}
.date-banner .date-main { font-size: 18px; font-weight: 800; }
.date-banner .date-sub { font-size: 12.5px; opacity: .9; }

.window-locked {
    background: linear-gradient(120deg, #C94545, #E86A6A);
    color: #fff;
    border-radius: var(--card-radius);
    padding: 18px;
    text-align: center;
    font-weight: 700;
    box-shadow: var(--shadow);
}

.student-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--cream-2);
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.student-row .student-name {
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    color: var(--teal-dark);
    display: flex;
    align-items: center;
    gap: 6px;
}
.student-row .student-name:hover { text-decoration: underline; }

.status-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.status-btn {
    border: 2px solid transparent;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    color: #fff;
    opacity: .55;
    transition: opacity .15s, transform .1s;
}
.status-btn:active { transform: scale(0.95); }
.status-btn.active { opacity: 1; box-shadow: 0 4px 10px rgba(0,0,0,0.18); border-color: rgba(255,255,255,0.6); }
.status-present { background: var(--teal-light); }
.status-late { background: var(--amber); }
.status-excused_absent { background: var(--info); }
.status-unexcused_absent { background: var(--danger); }

.save-bar {
    position: sticky;
    bottom: 0;
    background: #fff;
    padding: 14px;
    box-shadow: 0 -6px 20px rgba(0,0,0,0.08);
    border-radius: 18px 18px 0 0;
    display: flex;
    justify-content: center;
    z-index: 10;
    margin-top: 10px;
}

/* ============ تقویم سالانه/ماهانه ============ */
.year-grid { display: flex; flex-direction: column; gap: 16px; }
.month-block h4 { margin: 0 0 8px; font-size: 14px; color: var(--teal-dark); }
.day-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(26px, 1fr));
    gap: 4px;
}
.day-cell {
    aspect-ratio: 1;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #fff;
    font-weight: 700;
}
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; margin-top: 10px; }
.legend .dot { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-left: 5px; vertical-align: middle; }

/* ============ جدول‌ها ============ */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 8px; text-align: right; border-bottom: 1px solid var(--cream-2); }
th { color: #8a8578; font-weight: 700; font-size: 12.5px; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; color: #fff; }
.badge-teal { background: var(--teal-light); }
.badge-amber { background: var(--amber); }
.badge-gray { background: #B8B2A2; }

.tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.tab-btn { padding: 8px 16px; border-radius: 999px; border: 1.5px solid var(--cream-2); background: #fff; font-family: inherit; font-weight: 700; font-size: 13px; cursor: pointer; color: #8a8578; }
.tab-btn.active { background: var(--teal); color: #fff; border-color: var(--teal); }

.class-list { display: flex; flex-direction: column; gap: 8px; }
.class-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px; border-radius: 14px; background: var(--cream-2);
    cursor: pointer; transition: background .15s;
}
.class-item:hover { background: #E9E3D3; }
.class-item .cname { font-weight: 800; color: var(--teal-dark); }
.class-item .cteacher { font-size: 12.5px; color: #8a8578; }

.modal-overlay {
    position: fixed; inset: 0; background: rgba(20,30,25,0.55);
    display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px;
}
.modal-box {
    background: #fff; border-radius: 20px; max-width: 520px; width: 100%;
    max-height: 88vh; overflow-y: auto; padding: 20px; box-shadow: var(--shadow-lg);
}
.modal-close { float: left; background: none; border: none; font-size: 20px; cursor: pointer; color: #8a8578; }

.empty-state { text-align: center; padding: 40px 20px; color: #a39d8c; }
.empty-state .e-emoji { font-size: 40px; margin-bottom: 10px; }

.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); }
.form-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

.toast {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
    background: var(--teal-dark); color: #fff; padding: 12px 22px; border-radius: 999px;
    font-size: 14px; box-shadow: var(--shadow-lg); z-index: 200; opacity: 0; transition: opacity .3s, transform .3s;
    pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }

/* ============ صفحه پاسخ والدین ============ */
.respond-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--info), #2F5C96);
    padding: 20px;
}
.respond-card { background: #fff; border-radius: 24px; padding: 30px 24px; max-width: 420px; width: 100%; text-align: center; box-shadow: var(--shadow-lg); }
.respond-options { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.respond-btn {
    padding: 16px; border-radius: 14px; border: 2px solid var(--cream-2); background: var(--cream-2);
    font-family: inherit; font-size: 15px; font-weight: 700; cursor: pointer; color: var(--ink);
}
.respond-btn:hover { border-color: var(--teal-light); }

@media (max-width: 640px) {
    .app-main { padding: 12px; }
    .student-row { flex-direction: column; align-items: stretch; }
    .status-buttons { justify-content: stretch; }
    .status-btn { flex: 1; }
}
