/* ViVek auth page — matches terminal design tokens and modal styling */

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

body.auth-page {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Dimmed app shell visible behind the modal */
.auth-page-shell {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse 55% 45% at 15% 20%, rgba(255, 111, 97, 0.08), transparent 55%),
        radial-gradient(ellipse 50% 40% at 85% 15%, rgba(61, 184, 176, 0.06), transparent 50%),
        var(--bg-primary);
}

.auth-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 16px;
}

.auth-modal-scrim {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.auth-modal-content {
    position: relative;
    z-index: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    max-width: 400px;
    max-height: calc(100dvh - 40px);
    overflow-y: auto;
    box-shadow: 0 20px 40px var(--shadow-hover);
    animation: authModalIn 0.22s ease-out both;
}

@keyframes authModalIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.auth-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.auth-modal-close {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.auth-modal-close:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
    background: var(--bg-elevated, var(--bg-tertiary));
}

.auth-modal-close svg {
    width: 18px;
    height: 18px;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
    min-width: 0;
}

.auth-brand__mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), var(--vivek-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    color: #fff;
    box-shadow: 0 4px 16px rgba(255, 111, 97, 0.35);
    flex-shrink: 0;
}

.auth-brand__text {
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modal-title {
    margin-top: 0;
    margin-bottom: 16px;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-input {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
    font-family: var(--font-sans);
    font-size: 16px;
    transition: all 0.3s ease;
    width: 100%;
}

.auth-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 111, 97, 0.1);
}

.password-input-container {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.password-input-container .auth-input {
    padding-right: 45px;
    width: 100%;
}

.password-toggle {
    position: absolute;
    right: 8px;
    z-index: 3;
    cursor: pointer;
    user-select: none;
    font-size: 16px;
    opacity: 1;
    transition: opacity 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 6px;
    border-radius: 6px;
    color: var(--text-primary, #1a1a1a);
    /* Stays readable over browser yellow autofill backgrounds */
    background: color-mix(in srgb, var(--bg-primary, #fff) 88%, transparent);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--border, #ccc) 60%, transparent);
}

.password-toggle:hover {
    opacity: 1;
    background: var(--bg-primary, #fff);
}

.password-toggle svg,
.password-toggle i {
    color: inherit;
    stroke: currentColor;
}

/* Autofill paints yellow over the whole input; keep toggle above and contrast clear */
.password-input-container .auth-input:-webkit-autofill,
.password-input-container .auth-input:-webkit-autofill:hover,
.password-input-container .auth-input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text-primary, #1a1a1a);
    transition: background-color 99999s ease-out;
}

.auth-submit {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 20px;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.auth-submit:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--shadow-hover);
}

.auth-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.auth-divider {
    text-align: center;
    margin: 20px 0;
    position: relative;
}

.auth-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border);
}

.auth-divider span {
    background: var(--bg-secondary);
    padding: 0 15px;
    color: var(--text-secondary);
    font-size: 16px;
    position: relative;
}

.google-login-btn {
    width: 100%;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: all 0.2s ease;
    margin-bottom: 16px;
    font-family: var(--font-sans);
}

.google-login-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent);
    box-shadow: 0 2px 4px var(--shadow);
    transform: translateY(-1px);
}

.google-login-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.auth-switch {
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
    color: var(--text-secondary);
}

.auth-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    background: none;
    border: none;
    font: inherit;
    padding: 0;
}

.auth-link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.auth-hint {
    font-size: 13px;
    color: var(--text-secondary);
    margin: -4px 0 0 0;
    line-height: 1.45;
}

.signup-type-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 8px;
}

.signup-type-btn {
    width: 100%;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 15px;
    font-weight: 500;
    text-align: left;
    transition: all 0.2s ease;
}

.signup-type-btn:hover {
    border-color: var(--accent);
    background: var(--bg-secondary);
    transform: translateY(-1px);
}

.signup-type-btn strong {
    display: block;
    font-size: 16px;
    margin-bottom: 4px;
}

.signup-type-btn span {
    display: block;
    font-size: 13px;
    font-weight: 400;
    color: var(--text-secondary);
    line-height: 1.4;
}

.parent-uid-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.parent-uid-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.parent-uid-row .auth-input {
    flex: 1;
    margin: 0;
}

.parent-uid-remove {
    flex-shrink: 0;
    width: 40px;
    height: 42px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.parent-uid-remove:hover:not(:disabled) {
    border-color: var(--error);
    color: var(--error);
}

.parent-uid-remove:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.parent-uid-add-btn {
    width: 100%;
    padding: 10px 14px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.parent-uid-add-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.error-message {
    color: var(--error);
    font-size: 14px;
    margin-top: 8px;
    padding: 8px 12px;
    background: rgba(244, 67, 54, 0.1);
    border: 1px solid rgba(244, 67, 54, 0.3);
    border-radius: 6px;
    display: none;
}

.error-message:not(:empty) {
    display: block;
}

.error-message:empty {
    display: none !important;
    margin-top: 0;
    padding: 0;
    border: none;
    background: transparent;
}

.auth-panel[hidden] {
    display: none !important;
}

.auth-legal-notice {
    margin-top: 14px;
    font-size: 0.78rem;
    line-height: 1.45;
    color: var(--vivek-text-muted, #78716C);
    text-align: center;
}

.auth-legal-notice a {
    color: var(--vivek-brand, #FF6F61);
    text-decoration: none;
}

.auth-legal-notice a:hover {
    text-decoration: underline;
}

@media (prefers-reduced-motion: reduce) {
    .auth-modal-content {
        animation: none;
    }
}
