@font-face {
    font-family: Vazirmatn;
    src: url("fonts/Vazirmatn-Regular.woff2") format("woff2");
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: Vazirmatn;
    src: url("fonts/Vazirmatn-Bold.woff2") format("woff2");
    font-weight: 700;
    font-display: swap;
}

:root {
    --primary: #1769aa;
    --primary-dark: #104b7b;
    --background: #f3f6fb;
    --text: #1e293b;
    --muted: #64748b;
    --border: #e2e8f0;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    width: 100%;
    min-width: 0;
    font-size: 16px;
}

body {
    width: 100%;
    min-width: 0;
    margin: 0;
    direction: rtl;
    background: var(--background);
    color: var(--text);
    font: 16px/1.9 Vazirmatn, Tahoma, Arial, sans-serif;
}

input,
select,
button,
textarea {
    font: inherit;
}

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

a:hover {
    color: var(--primary-dark);
}

h1,
h2,
h3 {
    margin-top: 0;
    line-height: 1.7;
}

h1,
h2 {
    font-size: 22px;
}

h3 {
    font-size: 19px;
}

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 700;
}

input,
select,
textarea {
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 48px;
    padding: 10px 13px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font-family: inherit;
    font-size: 16px;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid #bfdbfe;
    border-color: var(--primary);
}

button,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 10px 20px;
    border: 0;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-family: inherit;
    font-size: 16px;
    cursor: pointer;
}

button:hover,
.btn:hover {
    background: var(--primary-dark);
    color: #fff;
}

.error {
    width: 100%;
    margin: 14px 0;
    padding: 12px 14px;
    border: 1px solid #fecaca;
    border-radius: 8px;
    background: #fff1f0;
    color: #c0392b;
    font-size: 15px;
    overflow-wrap: anywhere;
}

.muted,
small {
    color: var(--muted);
}

.container {
    width: calc(100% - 32px);
    max-width: 1100px;
    min-width: 0;
    margin: 24px auto;
}

.card,
.panel {
    min-width: 0;
    margin-bottom: 16px;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 4px 16px rgba(15, 35, 65, 0.05);
}

.grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.item {
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow-wrap: anywhere;
}

.label {
    color: var(--muted);
    font-size: 14px;
}

.value {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* صفحه ورود */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 24px 16px;
}

.login-page .login-card {
    width: 100%;
    max-width: 450px;
    min-width: 0;
    margin: 0;
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 5px 22px rgba(15, 35, 65, 0.08);
}

.login-page .login-card h2 {
    margin: 0 0 22px;
    font-size: 22px;
    font-weight: 700;
    text-align: center;
}

.login-page .login-card label {
    margin: 14px 0 6px;
}

.login-page .login-card input,
.login-page .login-card select {
    height: 48px;
    margin: 0;
}

.login-page .login-card button {
    width: 100%;
    margin-top: 22px;
}

/* صفحه جست‌وجو */

body:has(.search-page-layout) {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
}

.search-page-layout {
    width: calc(100% - 32px);
    max-width: 820px;
    min-width: 0;
    margin: auto;
    padding: 24px 0;
    font-size: 17px;
}

.search-topbar {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    width: 100%;
    min-width: 0;
    margin-bottom: 18px;
    padding: 14px 18px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
}

.search-topbar-user {
    order: 1;
    min-width: 0;
    color: var(--text);
    font-size: 15px;
    overflow-wrap: anywhere;
}

.search-topbar-logout {
    order: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 8px 14px;
    border-radius: 7px;
    background: var(--primary);
    color: #fff;
    font-size: 15px;
    white-space: nowrap;
}

.search-topbar-logout:hover {
    background: var(--primary-dark);
    color: #fff;
}

.search-page-layout .search-card {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0;
    padding: 28px 32px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 4px 18px rgba(15, 35, 65, 0.06);
}

.search-page-layout .search-card h2 {
    margin: 0 0 6px;
    font-size: 23px;
    text-align: center;
}

.search-subtitle {
    margin: 0 0 22px;
    color: var(--muted);
    font-size: 17px;
    text-align: center;
}

.search-form {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
}

.search-form label {
    margin: 14px 0 6px;
    font-size: 17px;
}

.search-form input,
.search-form select {
    height: 49px;
    font-size: 17px;
}

.search-form button {
    width: 100%;
    min-height: 49px;
    margin-top: 22px;
    font-size: 17px;
}

/* نتایج جست‌وجو و جدول‌ها */

.search-results-card {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 18px 0 0;
    padding: 24px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 4px 18px rgba(15, 35, 65, 0.06);
}

.search-results-card h3 {
    margin: 0 0 18px;
    font-size: 21px;
    text-align: center;
}

.search-results-card > p {
    margin: 12px 0 0;
    font-size: 16px;
    overflow-wrap: anywhere;
}

.table-wrap,
.search-results-card .table-wrap {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    max-width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 10px;
    text-align: right;
    border-bottom: 1px solid var(--border);
    overflow-wrap: anywhere;
}

.search-results-card table {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    table-layout: fixed;
    border-collapse: collapse;
    background: #fff;
    font-size: 16px;
    line-height: 2;
}

.search-results-card th,
.search-results-card td {
    padding: 13px 10px;
    vertical-align: middle;
}

.search-results-card th {
    background: #eaf2fa;
    color: #173b5c;
    font-size: 16px;
    font-weight: 700;
    text-align: center;
}

.search-results-card td {
    text-align: right;
}

.search-results-card tbody tr:nth-child(even) {
    background: #f8fafc;
}

.search-results-card tbody tr:hover {
    background: #edf5fc;
}

.search-results-card th:nth-child(1),
.search-results-card td:nth-child(1) {
    width: 19%;
}

.search-results-card th:nth-child(2),
.search-results-card td:nth-child(2) {
    width: 29%;
}

.search-results-card th:nth-child(3),
.search-results-card td:nth-child(3) {
    width: 22%;
    text-align: center;
}

.search-results-card th:nth-child(4),
.search-results-card td:nth-child(4) {
    width: 30%;
    text-align: center;
}

.search-results-card .view {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 7px 14px;
    border-radius: 7px;
    background: var(--primary);
    color: #fff;
    font-size: 15px;
    line-height: 1.7;
    white-space: nowrap;
}

.search-results-card .view:hover {
    background: var(--primary-dark);
    color: #fff;
}

.results-note {
    margin: 14px 0 0;
    color: var(--muted);
    font-size: 15px;
    overflow-wrap: anywhere;
}

/* صفحه اطلاعات دانش‌آموز */

.student-page {
    width: calc(100% - 32px);
    max-width: 900px;
    min-width: 0;
    margin: 20px auto;
}

.student-summary {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 8px;
}

.student-summary-item {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px 8px;
    min-width: 0;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
}

.student-summary-label {
    color: var(--muted);
    font-size: 15px;
    font-weight: 700;
}

.student-summary-value {
    min-width: 0;
    font-size: 17px;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.student-page .student-details-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.student-page .student-detail {
    display: grid;
    grid-template-columns: 155px minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}

.student-page .student-detail-label {
    display: block;
    margin: 0;
    color: var(--muted);
    font-size: 16px;
    font-weight: 700;
    line-height: 1.9;
}

.student-page .student-detail-value {
    display: block;
    min-width: 0;
    margin: 0;
    font-size: 16px;
    line-height: 1.9;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.student-page .student-detail.wide {
    grid-column: 1 / -1;
}

.student-actions {
    margin-top: 16px;
}

.student-actions a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 9px 16px;
    border-radius: 7px;
    background: var(--primary);
    color: #fff;
}

.student-actions a:hover {
    background: var(--primary-dark);
    color: #fff;
}

/* فرم ویرایش اطلاعات */

.edit-student-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: 24px;
}

.edit-student-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 0;
}

.edit-student-field.wide {
    grid-column: 1 / -1;
}

.edit-student-field label {
    margin-bottom: 0;
    font-size: 16px;
    font-weight: 700;
}

.edit-student-field input,
.edit-student-field textarea {
    width: 100%;
    min-width: 0;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font: inherit;
    font-size: 16px;
}

.edit-student-field textarea {
    min-height: 85px;
    resize: vertical;
}

.edit-student-field input:focus,
.edit-student-field textarea:focus {
    outline: 2px solid #bfdbfe;
    border-color: var(--primary);
}

/* لینک تغییر رمز عبور */

.password-link-container {
    margin-top: 10px;
    text-align: left;
}

.text-link {
    color: var(--primary);
    font-size: 12px;
    text-decoration: none;
}

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

/* صفحه تغییر رمز عبور */

.password-page-title {
    margin-bottom: 24px;
    text-align: center;
}

.password-form .edit-student-grid {
    gap: 18px;
}

.password-form .edit-student-field {
    margin-bottom: 4px;
}

.password-form .student-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
}

.password-form .student-actions button,
.password-form .student-actions a {
    margin: 0;
}

/* نمایش در موبایل */

@media screen and (max-width: 600px) {
    body {
        overflow-x: hidden;
        font-size: 16px;
    }

    h1,
    h2 {
        font-size: 20px;
    }

    .container,
    .student-page {
        width: calc(100% - 16px);
        margin: 10px auto;
    }

    .card,
    .panel {
        margin-bottom: 10px;
        padding: 14px;
    }

    .grid,
    .details {
        grid-template-columns: minmax(0, 1fr);
    }

    .login-page {
        padding: 16px 12px;
    }

    .login-page .login-card {
        padding: 22px 16px;
        border-radius: 12px;
    }

    .login-page .login-card h2 {
        font-size: 20px;
    }

    .login-page .login-card label {
        font-size: 15px;
    }

    .login-page .login-card input,
    .login-page .login-card select {
        font-size: 16px;
    }

    .search-page-layout {
        width: calc(100% - 24px);
        padding: 16px 0;
        font-size: 16px;
    }

    .search-topbar {
        gap: 8px;
        margin-bottom: 12px;
        padding: 11px;
    }

    .search-topbar-user,
    .search-topbar-logout {
        font-size: 14px;
    }

    .search-topbar-logout {
        min-height: 38px;
        padding: 7px 10px;
    }

    .search-page-layout .search-card {
        padding: 22px 16px;
        border-radius: 12px;
    }

    .search-page-layout .search-card h2 {
        font-size: 20px;
    }

    .search-subtitle {
        margin-bottom: 18px;
        font-size: 16px;
    }

    .search-form label {
        font-size: 16px;
    }

    .search-form input,
    .search-form select {
        height: 48px;
        font-size: 16px;
    }

    .search-form button {
        min-height: 48px;
        margin-top: 18px;
        font-size: 16px;
    }

    .search-results-card {
        margin-top: 14px;
        padding: 16px 10px;
        border-radius: 12px;
    }

    .search-results-card h3 {
        margin-bottom: 14px;
        font-size: 19px;
    }

    .search-results-card table {
        font-size: 15px;
        line-height: 1.9;
    }

    .search-results-card th,
    .search-results-card td {
        padding: 11px 5px;
        font-size: 15px;
        line-height: 1.9;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .search-results-card th {
        font-size: 14px;
    }

    .search-results-card .view {
        min-height: 36px;
        padding: 6px 8px;
        font-size: 14px;
        white-space: normal;
    }

    .results-note {
        font-size: 14px;
        line-height: 1.9;
    }

    .student-summary {
        grid-template-columns: minmax(0, 1fr);
    }

    .student-page .student-detail,
    .student-page .student-detail.wide {
        grid-column: auto;
        grid-template-columns: 110px minmax(0, 1fr);
        gap: 7px;
        padding: 10px;
    }

    .student-page .student-detail-label,
    .student-page .student-detail-value {
        font-size: 15px;
        line-height: 1.9;
    }

    .student-summary-label {
        font-size: 14px;
    }

    .student-summary-value {
        font-size: 16px;
    }

    .edit-student-grid,
    .password-form .edit-student-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
    }

    .edit-student-field.wide {
        grid-column: auto;
    }

    .password-form .student-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .password-form .student-actions button,
    .password-form .student-actions a {
        width: 100%;
        text-align: center;
    }

    th,
    td {
        padding: 8px 5px;
        font-size: 13px;
    }
}

@media screen and (max-width: 360px) {
    .login-page .login-card {
        padding: 18px 12px;
    }

    .search-page-layout {
        width: calc(100% - 16px);
    }

    .search-page-layout .search-card {
        padding: 18px 11px;
    }

    .search-page-layout .search-card h2 {
        font-size: 18px;
    }

    .search-results-card {
        padding: 12px 5px;
    }

    .search-results-card th,
    .search-results-card td {
        padding: 9px 3px;
        font-size: 13px;
    }

    .search-results-card th {
        font-size: 12px;
    }

    .search-results-card .view {
        padding: 5px;
        font-size: 12px;
    }
}