/* login.css — Deep Space Glass v5.0 / Neural Lattice theme */

/* ── Fonts (LINESeedTH — same as dashboard, no external CDN) ── */
@font-face {
    font-family: 'LINESeedTH';
    src: local('LINE Seed Sans TH Thin'),
         url('/static/fonts/LINESeedSansTH_Th.ttf') format('truetype');
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'LINESeedTH';
    src: local('LINE Seed Sans TH'),
         url('/static/fonts/LINESeedSansTH_Rg.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'LINESeedTH';
    src: local('LINE Seed Sans TH ExtraBold'),
         url('/static/fonts/LINESeedSansTH_XBd.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* ── Design tokens (matches dashboard.css) ─────────────────── */
:root {
    --bg-base:      #06070d;
    --bg-1:         #0c1018;
    --accent:       #0d9488;
    --accent-light: #2dd4bf;
    --accent-dim:   rgba(13, 148, 136, 0.12);
    --t1:  #edf2f7;
    --t2:  #94a3b8;
    --t3:  #6b7fa0;
    --line:   rgba(255, 255, 255, 0.07);
    --line-2: rgba(255, 255, 255, 0.14);
    --ok:  #22c55e;
    --err: #ef4444;
    --r-sm: 4px;
    --r:    6px;
    --r-lg: 14px;
}

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

/* ── Body ──────────────────────────────────────────────────── */
body {
    font-family: 'LINESeedTH', 'Prompt', 'Inter', -apple-system, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--t1);
    background-color: var(--bg-base);
    /* Teal glow from top — identical to dashboard body */
    background-image: radial-gradient(
        ellipse 120% 60% at 50% -10%,
        rgba(13, 148, 136, 0.12) 0%,
        transparent 65%
    );
    background-attachment: fixed;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* ── Canvas background (Neural Lattice) ────────────────────── */
#lattice-canvas {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

/* ── Login card ─────────────────────────────────────────────── */
.login-card {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 400px;
    padding: 40px 36px 32px;

    background: rgba(8, 12, 22, 0.90);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);

    /* Teal accent on top edge — signature detail */
    border: 1px solid var(--line);
    border-top: 1px solid rgba(13, 148, 136, 0.55);
    border-radius: var(--r-lg);
    box-shadow:
        0 0 0 1px rgba(13, 148, 136, 0.06),
        0 -2px 24px rgba(13, 148, 136, 0.07),
        0 32px 64px rgba(0, 0, 0, 0.85);

    opacity: 0;
    transform: translateY(20px) scale(0.97);
    animation: card-in 320ms cubic-bezier(0.16, 1, 0.3, 1) 80ms forwards;
}

@keyframes card-in {
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Header ─────────────────────────────────────────────────── */
.login-header {
    text-align: center;
    margin-bottom: 28px;
}

/* ── Brand block (logo + org names) ── */
.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 auto 20px;
    width: fit-content;
    opacity: 0;
    animation: fade-up 280ms cubic-bezier(0.16, 1, 0.3, 1) 200ms forwards;
}
.login-logo-wrap {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    padding: 4px;
}
.login-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.login-org {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
    text-align: left;
}
.login-org-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-light);
    letter-spacing: 0.05em;
}
.login-org-name strong {
    font-weight: 700;
    color: var(--accent-light);
}
.login-org-name:nth-child(2) {
    color: var(--t1);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.04em;
}
.login-org-name:nth-child(2) strong {
    color: var(--t1);
}
.login-org-team {
    font-size: 9px;
    font-weight: 600;
    color: var(--t3);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    margin-top: 2px;
}

.login-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--t1);
    letter-spacing: -0.01em;
    margin-bottom: 6px;
    opacity: 0;
    animation: fade-up 280ms cubic-bezier(0.16, 1, 0.3, 1) 260ms forwards;
}

.login-subtitle {
    font-size: 13px;
    color: var(--t3);
    opacity: 0;
    animation: fade-up 280ms cubic-bezier(0.16, 1, 0.3, 1) 310ms forwards;
}

@keyframes fade-up {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Form fields ────────────────────────────────────────────── */
.field-group {
    margin-bottom: 16px;
}

.field-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--t2);
    margin-bottom: 6px;
}

.field-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.field-icon {
    position: absolute;
    left: 13px;
    font-size: 13px;
    color: var(--t3);
    pointer-events: none;
    z-index: 1;
    transition: color 160ms cubic-bezier(0.4, 0, 0.2, 1);
}

.field-wrap:focus-within .field-icon {
    color: var(--accent);
}

.field-wrap input {
    width: 100%;
    background: var(--bg-1);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: var(--r);
    padding: 10px 14px 10px 38px;
    color: var(--t1);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 160ms cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow   160ms cubic-bezier(0.4, 0, 0.2, 1);
}

.field-wrap input::placeholder {
    color: var(--t3);
}

.field-wrap input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.18);
}

/* Password field needs room for toggle button */
#password { padding-right: 40px; }

.toggle-pw {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    color: var(--t3);
    cursor: pointer;
    padding: 4px 6px;
    font-size: 12px;
    border-radius: var(--r-sm);
    transition: color 160ms;
    line-height: 1;
}
.toggle-pw:hover { color: var(--t2); }

/* ── Actions row ─────────────────────────────────────────────── */
.field-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    font-size: 13px;
}

/* Custom checkbox */
.remember-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--t2);
    user-select: none;
}
.remember-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0; height: 0;
}
.check-box {
    width: 16px;
    height: 16px;
    border: 1px solid var(--line-2);
    border-radius: var(--r-sm);
    background: var(--bg-1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: border-color 160ms, background 160ms;
}
.remember-label input:checked ~ .check-box {
    border-color: var(--accent);
    background: rgba(13, 148, 136, 0.20);
}
.remember-label input:checked ~ .check-box::after {
    content: '';
    display: block;
    width: 8px;
    height: 5px;
    border-left:   1.5px solid var(--accent-light);
    border-bottom: 1.5px solid var(--accent-light);
    transform: rotate(-45deg) translateY(-1px);
}

.forgot-btn {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    padding: 0;
    transition: color 160ms;
}
.forgot-btn:hover { color: var(--accent-light); }

/* ── Alerts ─────────────────────────────────────────────────── */
.error-alert,
.info-alert {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
    border-radius: var(--r);
    margin-bottom: 16px;
    font-size: 13px;
    line-height: 1.45;
}
.error-alert {
    background: rgba(239, 68, 68, 0.10);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #fca5a5;
    animation: shake 0.4s ease-in-out;
}
.info-alert {
    background: rgba(56, 189, 248, 0.08);
    border: 1px solid rgba(56, 189, 248, 0.25);
    color: #7dd3fc;
}
.error-alert.hidden,
.info-alert.hidden { display: none; }

.error-alert i,
.info-alert i { flex-shrink: 0; margin-top: 2px; }

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60%  { transform: translateX(-5px); }
    40%, 80%  { transform: translateX(5px); }
}

/* ── Submit button ───────────────────────────────────────────── */
.login-btn {
    width: 100%;
    padding: 11px 16px;
    background: linear-gradient(135deg, #0d9488 0%, #0891b2 100%);
    color: #fff;
    border: none;
    border-radius: var(--r);
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 2px 14px rgba(13, 148, 136, 0.30);
    position: relative;
    overflow: hidden;
    transition: transform 160ms cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 160ms cubic-bezier(0.4, 0, 0.2, 1),
                background  240ms;
}

/* Shimmer on hover */
.login-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent       0%,
        rgba(255,255,255,0.10) 50%,
        transparent       100%
    );
    background-size: 200% 100%;
    background-position: -100% 0;
    transition: background-position 0.55s ease;
}
.login-btn:hover:not(:disabled)::after {
    background-position: 100% 0;
}

.login-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(13, 148, 136, 0.45);
}
.login-btn:active:not(:disabled) {
    transform: scale(0.97) translateY(0);
    box-shadow: 0 1px 8px rgba(13, 148, 136, 0.25);
}
.login-btn:disabled {
    opacity: 0.75;
    cursor: not-allowed;
    transform: none;
}
.login-btn.success {
    background: var(--ok);
    box-shadow: 0 2px 14px rgba(34, 197, 94, 0.30);
}

/* Spinner */
.btn-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin-login 0.55s linear infinite;
    flex-shrink: 0;
}
.btn-spinner.hidden { display: none; }
.btn-arrow.hidden   { display: none; }

@keyframes spin-login {
    to { transform: rotate(360deg); }
}

/* ── Footer ─────────────────────────────────────────────────── */
.login-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 11px;
    color: var(--t3);
    line-height: 1.5;
}

/* ── Reduced motion ──────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .login-card,
    .login-brand,
    .login-title,
    .login-subtitle {
        animation: none;
        opacity: 1;
        transform: none;
    }
    .login-btn,
    .login-btn::after,
    .field-wrap input,
    .field-icon { transition: none; }
}
