/* ═══════════════════════════════════════════════════════════════════════════
   CSE Stock Agent — Login Page
   ═══════════════════════════════════════════════════════════════════════════ */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0b0f19;
    --bg-secondary: #111827;
    --bg-card: #1a1f2e;
    --bg-card-hover: #1f2537;
    --bg-surface: #252b3b;
    --bg-elevated: #2d3548;

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-dim: #475569;

    --blue: #3b82f6;
    --blue-glow: rgba(59, 130, 246, 0.15);
    --blue-border: rgba(59, 130, 246, 0.35);
    --green: #10b981;
    --red: #ef4444;
    --red-glow: rgba(239, 68, 68, 0.12);

    --border: rgba(148, 163, 184, 0.08);
    --border-light: rgba(148, 163, 184, 0.14);
    --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.6);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --duration: 0.22s;
}

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(148, 163, 184, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, 0.025) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
    z-index: 0;
}

/* ── Wordmark ─────────────────────────────────────────────────────────────── */
.wordmark {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2.5rem;
    position: relative;
    z-index: 1;
}

.wordmark-icon {
    font-size: 2rem;
    color: var(--blue);
    filter: drop-shadow(0 0 10px rgba(59, 130, 246, 0.5));
    line-height: 1;
}

.wordmark-text h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.wordmark-text p {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 500;
}

/* ── Card ─────────────────────────────────────────────────────────────────── */
.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 2.25rem 2.5rem;
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 1;
    animation: cardIn 0.4s var(--ease) both;
}

@keyframes cardIn {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.card-header {
    margin-bottom: 1.75rem;
}

.card-header h2 {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-primary);
}

.card-header p {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

/* ── Step indicator ───────────────────────────────────────────────────────── */
.step-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.step {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    transition: all var(--duration) var(--ease);
    border: 1px solid var(--border-light);
    color: var(--text-muted);
    background: var(--bg-surface);
}

.step.active {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff;
}

.step.done {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
}

.step-line {
    flex: 1;
    height: 1px;
    background: var(--border-light);
}

.step-line.done {
    background: var(--green);
}

/* ── Form ─────────────────────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 1.1rem;
}

label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    letter-spacing: 0.01em;
}

input[type="email"],
input[type="password"],
input[type="text"] {
    width: 100%;
    padding: 0.65rem 0.9rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

input[type="email"]:focus,
input[type="password"]:focus,
input[type="text"]:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

input::placeholder {
    color: var(--text-dim);
}

/* ── OTP input ────────────────────────────────────────────────────────────── */
.otp-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    padding: 0.6rem 0.85rem;
    background: var(--blue-glow);
    border: 1px solid var(--blue-border);
    border-radius: var(--radius-sm);
    line-height: 1.45;
}

input.otp-field {
    text-align: center;
    font-size: 1.6rem;
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: 0.4em;
    padding: 0.75rem;
}

/* ── Button ───────────────────────────────────────────────────────────────── */
.btn-primary {
    width: 100%;
    padding: 0.75rem;
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--duration) var(--ease);
    margin-top: 0.5rem;
    position: relative;
}

.btn-primary:hover:not(:disabled) {
    background: #2563eb;
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.35);
    transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary.loading::after {
    content: '';
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: translateY(-50%) rotate(360deg); }
}

.btn-link {
    background: none;
    border: none;
    color: var(--blue);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
    margin-top: 0.75rem;
    display: inline-block;
}

.btn-link:hover {
    color: #60a5fa;
}

/* ── Error / Alert ────────────────────────────────────────────────────────── */
.alert {
    padding: 0.65rem 0.9rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    margin-bottom: 1rem;
    display: none;
}

.alert.error {
    background: var(--red-glow);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.alert.success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #6ee7b7;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

/* ── Step panels ──────────────────────────────────────────────────────────── */
.step-panel {
    display: none;
}

.step-panel.active {
    display: block;
    animation: fadeIn 0.25s var(--ease);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateX(8px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ── Footer ───────────────────────────────────────────────────────────────── */
.card-footer-note {
    margin-top: 1.5rem;
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-dim);
}

footer {
    margin-top: 2rem;
    font-size: 0.7rem;
    color: var(--text-dim);
    text-align: center;
    position: relative;
    z-index: 1;
}

/* ── Password Input Wrapper & Toggle Visibility Button ────────────────────── */
.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.password-input-wrapper input {
    /* reserve space so text never slides under the icon */
    padding-right: 2.75rem !important;
}

.btn-toggle-password {
    position: absolute;
    right: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    /* 28 × 28 px hit-area — meets WCAG 2.5.5 target size */
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: var(--radius-sm);
    transition:
        color            var(--duration) var(--ease),
        background-color var(--duration) var(--ease),
        transform        var(--duration) var(--ease);
    /* keep the button above the input border */
    z-index: 1;
}

/* ── Hover: icon brightens, subtle pill background ── */
.btn-toggle-password:hover {
    color: var(--text-primary);
    background-color: rgba(148, 163, 184, 0.10);
    /* compensate for the translateY(-50%) already applied */
    transform: translateY(calc(-50% - 1px));
}

/* ── Focus-visible: keyboard / screen-reader ring ── */
.btn-toggle-password:focus {
    outline: none;
}
.btn-toggle-password:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
    color: var(--blue);
}

/* ── Active / pressed: icon sinks slightly ── */
.btn-toggle-password:active {
    transform: translateY(calc(-50% + 1px));
    background-color: rgba(148, 163, 184, 0.15);
    color: var(--text-primary);
}

/* ── aria-pressed="true" (password currently visible): tint icon blue ── */
.btn-toggle-password[aria-pressed="true"] {
    color: var(--blue);
}
.btn-toggle-password[aria-pressed="true"]:hover {
    color: #60a5fa;
    background-color: var(--blue-glow);
}

.eye-icon {
    display: block;
    flex-shrink: 0;
    pointer-events: none;
}
