.student-modal-overlay {
    position: fixed;
    inset: 0;

    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;

    box-sizing: border-box;
    background: transparent;
    z-index: 9999;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    color: #1f2f4f;
}

.student-modal-overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 0;
    background: rgba(15, 25, 40, 0.5);
    pointer-events: auto;
}

.student-modal-overlay.is-open,
.student-modal-overlay.is-closing {
    display: flex;
}

.student-modal-overlay.is-open::before {
    animation: modal-backdrop-in 0.28s ease-out both;
}

.student-modal-overlay.is-closing::before {
    animation: modal-backdrop-out 0.22s ease-in both;
}

.student-modal-overlay.is-open > .student-modal-card {
    z-index: 1;
    animation: modal-popup-in 220ms ease both;
}

.student-modal-overlay.is-closing > .student-modal-card {
    z-index: 1;
    animation: modal-popup-out 220ms ease both;
}

@media (prefers-reduced-motion: reduce) {
    .student-modal-overlay.is-open::before,
    .student-modal-overlay.is-closing::before,
    .student-modal-overlay.is-open > .student-modal-card,
    .student-modal-overlay.is-closing > .student-modal-card {
        animation: none !important;
    }
}

.student-modal-card > header.student-modal-header,
.student-modal-card > .student-modal-header {
    flex-shrink: 0;
}

#addStudentModernForm {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.student-modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
}

.student-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    border-bottom: 1px solid #e2e8f4;
    padding-bottom: 10px;
}

.student-modal-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.student-modal-title-copy {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.student-modal-user-icon {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: 10px;
    border: 1px solid #d8e1f2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #2f63c8;
    background: linear-gradient(145deg, #f4f8ff 0%, #eaf1ff 100%);
}

.student-modal-user-icon svg {
    width: 22px;
    height: 22px;
}

.student-modal-title-wrap h2 {
    margin: 0 0 4px;
    font-family: 'Gluten', cursive;
    font-size: 1.3rem;
    font-weight: 700;
    color: #1f2f4f;
}

.student-modal-title-wrap p {
    color: #74809a;
    font-size: 0.8rem;
    font-weight: 500;
}

.student-modal-close {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #7b879c;
    cursor: pointer;
}

.student-modal-close:hover {
    background: #f3f4f6;
}

.student-modal-close svg {
    width: 20px;
    height: 20px;
}

.student-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 10px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
}

.form-field label {
    font-size: 0.84rem;
    font-weight: 600;
    color: #444;
}

.required {
    color: #dc2626;
}

.student-modal-card .input-with-icon,
.student-modal-card .select-with-icon {
    position: relative;
}

.input-icon {
    position: absolute;
    top: 50%;
    left: 11px;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: #92a0ba;
    pointer-events: none;
}

.textarea-icon {
    top: 14px;
    transform: none;
}

.input-icon svg {
    width: 100%;
    height: 100%;
}

.student-modal-card input,
.student-modal-card select,
.student-modal-card textarea {
    width: 100%;
    border: 1px solid #d5dbe7;
    border-radius: 10px;
    font-size: 0.83rem;
    font-weight: 500;
    color: #1f2f4f;
    background: #fff;
    outline: none;
    transition: border-color 140ms ease, box-shadow 140ms ease;
}

.student-modal-card input,
.student-modal-card select {
    height: 42px;
}

.student-modal-card .input-with-icon input,
.student-modal-card .select-with-icon select {
    padding: 0 12px 0 38px;
}

.student-modal-card select#school,
.student-modal-card select#studentModalTeacher,
.student-modal-card select#editStudentTeacher {
    padding: 0 0 0 35px;
}

.student-modal-card select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, #6b7280 50%), linear-gradient(135deg, #6b7280 50%, transparent 50%);
    background-position: calc(100% - 17px) 17px, calc(100% - 11px) 17px;
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
    padding-right: 30px;
}

.student-modal-card input:focus,
.student-modal-card select:focus,
.student-modal-card textarea:focus {
    border-color: #7fa0e8;
    box-shadow: 0 0 0 2px rgba(127, 160, 232, 0.18);
}

.student-modal-card input::placeholder,
.student-modal-card textarea::placeholder {
    color: #a0adbf;
}

.phone-input-group {
    display: grid;
    grid-template-columns: 66px 48px minmax(0, 1fr);
    align-items: center;
    border: 1px solid #d5dbe7;
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
    height: 42px;
}

.phone-input-group:focus-within {
    border-color: #7fa0e8;
    box-shadow: 0 0 0 2px rgba(127, 160, 232, 0.18);
}

.country-display {
    height: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    border-right: 1px solid #d5dbe7;
    background: #f8fafc;
    cursor: pointer;
    padding: 0 8px;
}

.country-flag {
    width: 30px;
    height: 20px;
    object-fit: cover;
    border-radius: 7.5px;
    display: block;
}

.country-arrow svg {
    width: 14px;
    height: 14px;
    color: #64748b;
}

.country-picker-menu {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    z-index: 20;
    min-width: 210px;
    border: 1px solid #d5dbe7;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.18);
    padding: 4px;
}

.country-picker-option {
    width: 100%;
    border: none;
    background: transparent;
    border-radius: 8px;
    height: 34px;
    padding: 0 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    text-align: left;
    cursor: pointer;
    color: #2f3f5f;
    font-size: 0.8rem;
}

.country-picker-option:hover {
    background: #f4f8ff;
}

.country-picker-option img {
    width: 20px;
    height: 14px;
    border-radius: 20px;
    object-fit: cover;
}

.country-code {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    color: #334155;
    border-right: 1px solid #d5dbe7;
    font-weight: 600;
    font-size: 0.92rem;
}

.phone-input-group input {
    border: none;
    border-radius: 0;
    height: 100%;
    padding: 0 12px;
    box-shadow: none;
}

.phone-input-group input:focus {
    border: none;
    box-shadow: none;
}

.student-password-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 40px;
    gap: 6px;
    align-items: center;
}

.student-password-wrap input[readonly] {
    background: #f8fafc;
    padding: 0 10px;
}

.student-password-generate-btn {
    width: 40px;
    height: 40px;
    border: 1px solid #d5dbe7;
    border-radius: 10px;
    background: #eef2fb;
    color: #334155;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.student-password-generate-btn:hover {
    background: #e4ebfa;
}

.student-password-generate-btn svg {
    width: 35px;
    height: 35px;
}

.helper-text {
    margin: 0;
    font-size: 0.74rem;
    color: #74809a;
}

.full-width {
    grid-column: 1 / -1;
}

.textarea-wrap {
    position: relative;
}

.student-modal-card textarea {
    min-height: 106px;
    resize: vertical;
    padding: 12px 12px 30px 38px;
    line-height: 1.35;
}

.char-counter {
    position: absolute;
    right: 10px;
    bottom: 8px;
    font-size: 0.72rem;
    color: #74809a;
}

.info-box {
    margin-top: 10px;
    border: 1px solid #dbeafe;
    background: #eff6ff;
    border-radius: 10px;
    padding: 11px 12px;
    display: flex;
    gap: 10px;
}

.info-icon {
    color: #2563eb;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.info-icon svg {
    width: 100%;
    height: 100%;
}

.info-title {
    margin: 0 0 2px;
    font-weight: 700;
    font-size: 0.84rem;
}

.info-text {
    margin: 0;
    font-size: 0.79rem;
    color: #374151;
    line-height: 1.35;
}

.student-credentials-row {
    margin-top: 10px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 15px;
}

.student-birth-age-level-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px 14px;
}

/** Add-student overlay row: birth · age · teacher · level */
#studentModalOverlay .student-birth-age-level-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

/** Edit-student modal uses the same four-column row */
#editStudentModal .student-birth-age-level-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 1100px) {
    #studentModalOverlay .student-birth-age-level-row,
    #editStudentModal .student-birth-age-level-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.student-modal-footer {
    margin: 0;
    padding: 0;
    flex-shrink: 0;
    border: none;
}

.student-modal-card .footer-actions {
    position: absolute;
    right: var(--student-modal-actions-right);
    bottom: var(--student-modal-actions-bottom);
    z-index: 2;
}

.student-external-link-section {
    margin-top: 10px;
    flex: 1;
    min-width: 240px;
    max-width: 420px;
}

.student-modal-body .student-external-link-section {
    flex-grow: 0;
    align-self: flex-start;
}

.student-external-link-section label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
    color: #334155;
}

.student-external-link-input-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--border-color, #d8dee9);
    border-radius: 10px;
    background: #fff;
    box-sizing: border-box;
}

.student-external-link-input-wrapper input {
    width: 100%;
    border: 0;
    outline: 0;
    font-size: 13px;
    background: transparent;
    min-width: 0;
}

.student-external-link-icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
    color: #92a0ba;
}

.student-external-link-icon svg {
    width: 18px;
    height: 18px;
    display: block;
}

.student-external-link-section small {
    display: block;
    margin-top: 3px;
    font-size: 11px;
    color: #6b7280;
}

.footer-actions {
    display: inline-flex;
    gap: 8px;
    flex-shrink: 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;

    height: 36px;
    padding: 0 15px;

    border: none;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-cancel {
    background: #eceff1;
    color: #37474f;
}

.btn-cancel:hover {
    background: #dfe3e6;
}

.btn-primary {
    background: linear-gradient(135deg, #334461, #071630);
    color: #fff;
}

.btn-primary:hover {
    filter: brightness(1.06);
}

.btn-icon {
    width: 18px;
    height: 18px;
    display: inline-flex;
}

.btn-icon svg {
    width: 100%;
    height: 100%;
}

#school,
#studentModalTeacher,
#editStudentTeacher {
    padding: 0px 0px 0px 35px;
}

@media (max-width: 800px) {
    .student-modal-card {
        padding: 50px;
    }

    .student-form-grid {
        grid-template-columns: 1fr;
    }

    .student-modal-title-wrap h2 {
        font-size: 1.15rem;
    }

    .student-modal-title-wrap p {
        font-size: 0.76rem;
    }

    .student-credentials-row {
        grid-template-columns: 1fr;
    }

    .student-birth-age-level-row {
        grid-template-columns: 1fr;
    }

    .student-modal-footer {
        margin-top: 8px;
    }

    .student-modal-card .footer-actions {
        position: static;
        z-index: auto;
    }

    .student-modal-body {
        padding-bottom: 12px;
    }

    .footer-actions {
        display: flex;
        width: 100%;
        box-sizing: border-box;
    }

    .footer-actions .btn {
        flex: 1 1 0;
        justify-content: center;
    }
}
