/* surfaces-student-modal.css — Create Student Modal (.csm-*)
   Extracted from surfaces.css per P5.3 refactor 2026-05-24 */

/* Local error-ring shadow — no --shadow-danger token in variables.css */
.csm-overlay { --csm-shadow-error: 0 0 0 3px rgba(220, 38, 38, 0.12); }

.csm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-6);
    z-index: calc(var(--z-modal) - 1);
    opacity: 0;
    transition: opacity var(--transition-base);
}
.csm-overlay.is-open { opacity: 1; }

.csm-dialog {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    z-index: var(--z-modal);
}

.csm-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-5) var(--space-6) var(--space-4);
    border-bottom: 1px solid var(--border-default);
    flex-shrink: 0;
}
.csm-title {
    margin: 0;
    font-size: var(--text-body);
    font-weight: var(--weight-bold);
    color: var(--fg-primary);
    letter-spacing: -0.01em;
}
.csm-subtitle {
    margin: var(--space-1) 0 0;
    font-size: 12px;
    color: var(--color-neutral-400);
}
.csm-close-btn {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 6px;
    background: var(--color-neutral-100);
    border: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--color-neutral-600);
    transition: var(--transition-fast);
}
.csm-close-btn:hover { background: var(--color-neutral-200); }

.csm-body {
    padding: var(--space-5) var(--space-6);
    overflow-y: auto;
    flex: 1;
}

.csm-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
}
.csm-span-2 { grid-column: span 2; }

/* Floating label field */
.csm-field { position: relative; }
.csm-field-wrap {
    position: relative;
    border: 1.5px solid var(--border-default);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    transition: border-color var(--transition-base), box-shadow var(--transition-base);
}
.csm-field-wrap.is-focused {
    border-color: var(--border-focus);
    box-shadow: var(--shadow-focus);
}
.csm-field-wrap.is-error {
    border-color: var(--color-danger);
    box-shadow: var(--csm-shadow-error);
}
/* Error ring wins when both focused and invalid */
.csm-field-wrap.is-focused.is-error {
    border-color: var(--color-danger);
    box-shadow: var(--csm-shadow-error);
}
.csm-field-wrap.is-filled { border-color: var(--border-default); }

.csm-label {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: var(--text-body);
    font-weight: 400;
    color: var(--color-neutral-400);
    pointer-events: none;
    transition: all var(--transition-base);
    background: transparent;
}
.csm-label.is-up {
    top: 0;
    transform: translateY(-50%);
    font-size: 11px;
    font-weight: var(--weight-semibold);
    color: var(--color-primary-700);
    background: var(--bg-surface);
    padding: 0 var(--space-1);
    left: 8px;
    letter-spacing: 0.02em;
}
.csm-label.is-up.is-neutral { color: var(--color-neutral-600); }
.csm-label.is-up.is-error   { color: var(--color-danger); }

.csm-field-input {
    width: 100%;
    border: none;
    outline: none;
    background: transparent;
    font-family: inherit;
    font-size: var(--text-body);
    color: var(--fg-primary);
    padding: 14px 12px 6px;
    border-radius: var(--radius-md);
}
.csm-field-input::placeholder { color: transparent; }
select.csm-field-input { appearance: none; cursor: pointer; padding-right: var(--space-6); padding-top: 10px; padding-bottom: 10px; }

.csm-select-wrap { position: relative; }
.csm-select-chevron {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--color-neutral-400);
}

.csm-field-textarea {
    width: 100%;
    border: none;
    outline: none;
    background: transparent;
    font-family: inherit;
    font-size: var(--text-body);
    color: var(--fg-primary);
    padding: 22px 12px 8px;
    resize: none;
    border-radius: var(--radius-md);
    min-height: 80px;
}
.csm-textarea-wrap .csm-label { top: 18px; transform: none; }
.csm-textarea-wrap .csm-label.is-up { top: 0; transform: translateY(-50%); }

.csm-field-error {
    font-size: 11px;
    font-weight: var(--weight-semibold);
    color: var(--color-danger);
    margin-top: var(--space-1);
    display: flex;
    align-items: center;
    gap: var(--space-1);
}
.csm-field-hint {
    font-size: 11px;
    color: var(--color-neutral-400);
    margin-top: var(--space-1);
    text-align: right;
}

/* Section divider */
.csm-section-divider {
    grid-column: span 2;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin: var(--space-1) 0 0;
}
.csm-section-divider-line { flex: 1; height: 1px; background: var(--border-default); }
.csm-section-divider-label {
    font-size: 10px;
    font-weight: var(--weight-semibold);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-neutral-400);
    white-space: nowrap;
}

/* Check pills */
.csm-check-group { grid-column: span 2; }
.csm-check-group-label {
    font-size: 11px;
    font-weight: var(--weight-semibold);
    color: var(--color-neutral-600);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: var(--space-2);
}
.csm-pill-grid { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-2); }
.csm-pill {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 5px 11px;
    border-radius: 20px;
    border: 1.5px solid var(--border-default);
    font-size: 12px;
    font-weight: 500;
    color: var(--color-neutral-600);
    cursor: pointer;
    transition: var(--transition-fast);
    user-select: none;
    background: var(--bg-surface);
}
.csm-pill input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.csm-pill:has(input:checked) {
    background: var(--color-primary-light);
    border-color: var(--color-primary-700);
    color: var(--color-primary-700);
    font-weight: var(--weight-semibold);
}
.csm-pill-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    border: 1.5px solid var(--color-neutral-300);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--transition-fast);
}
.csm-pill:has(input:checked) .csm-pill-dot {
    background: var(--color-primary-700);
    border-color: var(--color-primary-700);
}

/* Footer */
.csm-footer {
    padding: var(--space-3) var(--space-6);
    border-top: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-3);
    flex-shrink: 0;
}

/* API error bar */
.csm-api-error {
    margin: 0 var(--space-6) var(--space-3);
    padding: var(--space-2) var(--space-3);
    background: var(--color-danger-light);
    border: 1px solid var(--color-danger);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    color: var(--color-danger);
}

/* Buttons */
.csm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    padding: 10px var(--space-5);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    cursor: pointer;
    border: none;
    transition: var(--transition-fast);
    white-space: nowrap;
}
.csm-btn-primary {
    background: var(--color-primary-700);
    color: var(--bg-surface);
    box-shadow: var(--shadow-primary);
}
.csm-btn-primary:hover:not(:disabled) { background: var(--color-primary-800); }
.csm-btn-primary:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }
.csm-btn-ghost {
    background: transparent;
    color: var(--color-neutral-600);
    border: 1px solid var(--border-default);
}
.csm-btn-ghost:hover:not(:disabled) { background: var(--color-neutral-100); }
.csm-btn-ghost:disabled { opacity: 0.4; cursor: not-allowed; }

@keyframes csm-spin { to { transform: rotate(360deg); } }
.csm-spinner { animation: csm-spin 1s linear infinite; }

/* Success toast — positioned inside dialog shell, outside scrollable .csm-body */
.csm-toast {
    position: absolute;
    bottom: var(--space-5);
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-neutral-900);
    color: var(--bg-surface);
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    white-space: nowrap;
    z-index: var(--z-toast, 80);
}
.csm-toast-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--color-success);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Visually-hidden live region (screen reader only) */
.csm-live {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

/* Responsive */
@media (max-width: 480px) {
    .csm-overlay { padding: var(--space-4); align-items: flex-end; }
    .csm-form-grid { grid-template-columns: 1fr; }
    .csm-span-2,
    .csm-section-divider,
    .csm-check-group { grid-column: 1; }
    .csm-footer { flex-direction: column-reverse; gap: var(--space-2); }
    .csm-footer .csm-btn { width: 100%; }
}

/* display:flex on these elements overrides UA [hidden]{display:none} — fix with higher specificity */
.csm-overlay[hidden],
.csm-toast[hidden],
.csm-field-error[hidden] { display: none; }
