/* ─── Login / Register Page Styles ──────────────────────────────────────── */

/* Toast */
.toast {
    position: fixed;
    top: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.8rem 1.8rem;
    border-radius: 30px;
    font-size: 0.95rem;
    font-weight: 500;
    z-index: 9999;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    transition: opacity 0.3s;
    white-space: nowrap;
}
.toast.hidden { opacity: 0; pointer-events: none; }
.toast-success { background: #10b981; color: white; }
.toast-error   { background: #ef4444; color: white; }
.toast-info    { background: #0284c7; color: white; }

/* Layout */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: stretch;
    padding: 2rem 1.5rem;
    gap: 0;
    max-width: 1100px;
    margin: 0 auto;
}

/* Left Brand Panel */
.login-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 3rem 2.5rem;
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
    background: linear-gradient(145deg, rgba(2,132,199,0.15), rgba(13,148,136,0.1));
}

.login-brand {
    text-align: center;
    margin-bottom: 2.5rem;
}

.brand-logo {
    height: 90px;
    width: auto;
    object-fit: contain;
    margin-bottom: 1.2rem;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.1));
}

.login-brand h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.3;
}

.login-brand .highlight {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-brand p {
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* Feature list */
.feature-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(255,255,255,0.5);
    padding: 0.8rem 1.2rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    transition: background 0.2s;
}

.feature-item:hover { background: rgba(255,255,255,0.8); }

.feature-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    color: white;
    border-radius: 10px;
    font-size: 1rem;
    flex-shrink: 0;
}

.btn-setup-link {
    background: none;
    border: 1px dashed #94a3b8;
    color: var(--text-muted);
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}
.btn-setup-link:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(2,132,199,0.05);
}

/* Right Form Panel */
.login-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 3rem 2.5rem;
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    border-left: 1px solid rgba(255,255,255,0.4);
}

/* Tabs */
.tab-bar {
    display: flex;
    background: #f1f5f9;
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 2rem;
    gap: 4px;
}

.tab-btn {
    flex: 1;
    padding: 0.65rem;
    border: none;
    border-radius: 9px;
    background: transparent;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.25s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.tab-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* Auth Forms */
.auth-form {
    display: none;
    flex-direction: column;
    flex: 1;
}
.auth-form.active { display: flex; }

.auth-form h2 {
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--text-main);
}
.form-subtitle {
    color: var(--text-muted);
    margin-top: 0.25rem;
    margin-bottom: 1.5rem;
}

.input-grid-auth {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.input-stack-auth {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.input-group-auth {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.input-group-auth label {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.input-group-auth label i { color: var(--primary); font-size: 0.85rem; }

.input-group-auth input,
.input-group-auth select {
    padding: 0.75rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    background: rgba(255,255,255,0.8);
    transition: all 0.25s;
    color: var(--text-main);
}

.input-group-auth input:focus,
.input-group-auth select:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(2,132,199,0.12);
}

/* Password with toggle */
.password-wrap {
    position: relative;
    display: flex;
}
.password-wrap input { flex: 1; padding-right: 2.8rem; }
.btn-toggle-pw {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0;
}
.btn-toggle-pw:hover { color: var(--primary); }

/* Submit Button */
.btn-auth {
    margin-top: auto;
    padding: 0.9rem;
    width: 100%;
    border: none;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(2,132,199,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
}
.btn-auth:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(2,132,199,0.45);
}
.btn-auth:disabled { opacity: 0.7; cursor: not-allowed; }

/* Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
.spinner.hidden { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Setup Modal */
.setup-modal-content {
    max-width: 550px;
    padding: 2rem;
    background: white;
    text-align: center;
}
.setup-modal-header {
    margin-bottom: 1.5rem;
}
.setup-modal-header h2 {
    margin: 0.5rem 0 0.25rem;
    font-size: 1.3rem;
}
.setup-modal-header p { color: var(--text-muted); font-size: 0.9rem; }

.setup-step {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    background: #f8fafc;
    padding: 0.8rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.6rem;
    text-align: left;
    font-size: 0.9rem;
}
.step-badge {
    min-width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.setup-step a { color: var(--primary); }

.setup-input-group {
    text-align: left;
    margin: 1rem 0;
}
.setup-input-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
}
.setup-input-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
}
.setup-input-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(2,132,199,0.12);
}

.btn-setup-save {
    width: 100%;
    padding: 0.8rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}
.btn-setup-save:hover { opacity: 0.9; }

/* Navbar in main app */
.user-navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.6);
    border-radius: var(--radius-lg);
    padding: 0.85rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-soft);
    position: sticky;
    top: 1rem;
    z-index: 100;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

.user-info-text .user-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-main);
}
.user-info-text .user-school {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    background: none;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}
.btn-logout:hover {
    border-color: var(--risk-color);
    color: var(--risk-color);
    background: var(--risk-bg);
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.btn-admin-settings {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: 1px solid #bae6fd;
    border-radius: 20px;
    background: rgba(2,132,199,0.06);
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--primary);
    cursor: pointer;
    transition: all 0.2s;
}
.btn-admin-settings:hover {
    background: rgba(2,132,199,0.15);
    border-color: var(--primary);
}
.btn-admin-settings.hidden { display: none; }

/* Responsive */
@media (max-width: 768px) {
    .login-wrapper {
        flex-direction: column;
        padding: 1rem;
        gap: 0;
        min-height: 100vh;
    }
    .login-left {
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        padding: 1.5rem;
    }
    .login-right {
        border-radius: 0 0 var(--radius-lg) var(--radius-lg);
        border-left: none;
        border-top: 1px solid rgba(255,255,255,0.4);
        padding: 1.5rem;
    }
    .input-grid-auth { grid-template-columns: 1fr; }

    /* แสดง 4 โรค ใต้ brand section บนมือถือ */
    .feature-list {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.6rem;
        margin-top: 1rem;
        margin-bottom: 0;
    }
    .feature-item {
        padding: 0.6rem 0.8rem;
        font-size: 0.82rem;
        gap: 0.6rem;
    }
    .feature-icon {
        width: 28px;
        height: 28px;
        font-size: 0.8rem;
        flex-shrink: 0;
    }
    .brand-logo { height: 60px; }
    .login-brand h1 { font-size: 1.3rem; }
}
