/* =====================================================
   ระบบจัดการผลการเรียน — Base Stylesheet
   ===================================================== */

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

:root {
    --color-primary:       #1a56db;
    --color-primary-dark:  #1343b0;
    --color-primary-light: #e8f0fe;
    --color-danger:        #e02424;
    --color-success:       #057a55;
    --color-warning:       #c27803;
    --color-info:          #0e9f6e;

    --color-bg:            #f3f4f6;
    --color-surface:       #ffffff;
    --color-border:        #d1d5db;
    --color-text:          #111827;
    --color-text-muted:    #6b7280;

    --radius-sm:  4px;
    --radius-md:  8px;
    --radius-lg:  12px;

    --shadow-sm:  0 1px 2px rgba(0,0,0,.06);
    --shadow-md:  0 4px 12px rgba(0,0,0,.08);
    --shadow-lg:  0 8px 24px rgba(0,0,0,.12);

    --font-sans:  'Sarabun', 'Noto Sans Thai', sans-serif;
    --font-size-base: 15px;
    --line-height: 1.6;
}

html { font-size: var(--font-size-base); }

body {
    font-family: var(--font-sans);
    line-height: var(--line-height);
    color: var(--color-text);
    background: var(--color-bg);
}

/* ── Auth Layout ────────────────────────────────────── */

.auth-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, #1a56db 0%, #0e9f6e 100%);
}

.auth-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.auth-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 420px;
}

.auth-card__header {
    text-align: center;
    margin-bottom: 1.75rem;
}

.auth-card__title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.3;
}

.auth-card__subtitle {
    color: var(--color-text-muted);
    margin-top: .375rem;
    font-size: .9rem;
}

.auth-card__footer {
    text-align: center;
    margin-top: 1.25rem;
}

/* ── Form ───────────────────────────────────────────── */

.auth-form { display: flex; flex-direction: column; gap: 1.125rem; }

.form-group { display: flex; flex-direction: column; gap: .375rem; }

.form-group--row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

.form-label {
    font-size: .875rem;
    font-weight: 600;
    color: var(--color-text);
}

.form-control {
    width: 100%;
    padding: .625rem .875rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: .95rem;
    color: var(--color-text);
    background: var(--color-surface);
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}

.form-control:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(26,86,219,.15);
}

.input-with-toggle {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-toggle .form-control {
    padding-right: 2.75rem;
}

.toggle-password {
    position: absolute;
    right: .75rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
    line-height: 1;
    opacity: .5;
    transition: opacity .15s;
}

.toggle-password:hover { opacity: 1; }

.checkbox-label {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .875rem;
    cursor: pointer;
    user-select: none;
}

/* ── Buttons ────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .625rem 1.25rem;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: .95rem;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, transform .1s, box-shadow .15s;
    white-space: nowrap;
}

.btn:active { transform: translateY(1px); }

.btn--primary {
    background: var(--color-primary);
    color: #fff;
}

.btn--primary:hover {
    background: var(--color-primary-dark);
    box-shadow: var(--shadow-sm);
}

.btn--full { width: 100%; }

/* ── Links ──────────────────────────────────────────── */

.link-subtle {
    font-size: .875rem;
    color: var(--color-primary);
    text-decoration: none;
}

.link-subtle:hover { text-decoration: underline; }

/* ── Flash messages ─────────────────────────────────── */

.flash-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    max-width: 380px;
    width: calc(100% - 2rem);
}

.flash {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .75rem;
    padding: .875rem 1rem;
    border-radius: var(--radius-md);
    font-size: .9rem;
    box-shadow: var(--shadow-md);
    animation: slideIn .2s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(1rem); }
    to   { opacity: 1; transform: translateX(0); }
}

.flash--success { background: #ecfdf5; color: var(--color-success); border: 1px solid #a7f3d0; }
.flash--error   { background: #fef2f2; color: var(--color-danger);  border: 1px solid #fecaca; }
.flash--warning { background: #fffbeb; color: var(--color-warning); border: 1px solid #fde68a; }
.flash--info    { background: #ecfdf5; color: var(--color-info);    border: 1px solid #a7f3d0; }

.flash__close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    opacity: .6;
    padding: 0;
    flex-shrink: 0;
}

.flash__close:hover { opacity: 1; }
