/**
 * Enterprise Login Styles
 *
 * Distinctive school-facing login with Snappy's brand personality.
 * Deep navy-purple backdrop differentiates enterprise from family entry.
 * Reuses auth-form / auth-error / snappy-btn from shared design system.
 */

/* ==========================================================================
   Login Page Layout
   ========================================================================== */

html.enterprise-page,
html.enterprise-page body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    height: 100%;
}

.enterprise-login {
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--snappy-brand-primary-dark);
    background-image:
        radial-gradient(ellipse 80% 60% at 50% 0%, rgba(206, 93, 254, 0.12) 0%, transparent 60%),
        radial-gradient(circle at 20% 80%, rgba(199, 188, 255, 0.06) 0%, transparent 40%);
    font-family: var(--snappy-font-primary), sans-serif;
    padding: var(--snappy-space-6);
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
}

/* Subtle grain texture overlay */
.enterprise-login::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
}

.enterprise-login__card {
    position: relative;
    z-index: 1;
    /* Login page lives outside the `.snappy-design-system` scoped box-sizing
       reset → default content-box. Without this, the card's padding adds to
       `width:100%` and overflows the viewport (most visibly at ≤480px where
       the parent padding drops to 0 and the card goes full-bleed). */
    box-sizing: border-box;
    background: var(--snappy-white);
    border-radius: var(--snappy-radius-2xl);
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.25),
        0 0 0 1px rgba(255, 255, 255, 0.05);
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
    text-align: center;
    animation: cardAppear 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

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

/* ==========================================================================
   Branding
   ========================================================================== */

.enterprise-login__logo {
    width: 80px;
    height: auto;
    margin-bottom: 0.75rem;
}

.enterprise-login__brand {
    font-family: var(--snappy-font-logo), var(--snappy-font-primary), sans-serif;
    font-size: var(--snappy-text-subheading);
    font-weight: bold;
    color: var(--snappy-brand-primary-dark);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0 0 0.25rem 0;
}

.enterprise-login__subtitle {
    font-size: 0.9rem;
    color: var(--snappy-gray-500);
    margin: 0 0 2rem 0;
    font-weight: var(--snappy-font-weight-normal);
}

/* ==========================================================================
   Role Selector
   ========================================================================== */

.enterprise-login__prompt {
    font-size: 1.05rem;
    font-weight: var(--snappy-font-weight-semibold);
    color: var(--snappy-brand-primary-dark);
    margin: 0 0 1rem 0;
}

.enterprise-login__roles {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.enterprise-login__role-btn {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.9rem 1.125rem;
    font-family: var(--snappy-font-primary), sans-serif;
    font-size: var(--snappy-text-body-small);
    font-weight: var(--snappy-font-weight-semibold);
    text-align: left;
    border: 2px solid var(--snappy-gray-200, var(--snappy-gray-100));
    border-radius: 0.875rem;
    background: var(--snappy-white);
    color: var(--snappy-gray-900);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, transform 0.15s, box-shadow 0.2s;
}

.enterprise-login__role-btn:hover {
    border-color: var(--snappy-brand-primary);
    background: var(--snappy-brand-primary-very-light);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(206, 93, 254, 0.12);
}

.enterprise-login__role-btn:active {
    transform: translateY(0);
}

.enterprise-login__role-icon {
    width: 36px;
    height: 36px;
    border-radius: 0.625rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.enterprise-login__role-icon--admin {
    background: rgba(206, 93, 254, 0.12);
    color: var(--snappy-brand-primary);
}

.enterprise-login__role-icon--teacher {
    background: rgba(6, 167, 125, 0.12);
    color: var(--snappy-success);
}

.enterprise-login__role-icon--student {
    background: rgba(253, 215, 130, 0.2);
    color: #C9A85F;
}

.enterprise-login__role-label {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.enterprise-login__role-name {
    line-height: 1.2;
}

.enterprise-login__role-desc {
    font-size: 0.75rem;
    font-weight: var(--snappy-font-weight-normal);
    color: var(--snappy-gray-500);
    line-height: 1.2;
}

/* Arrow indicator */
.enterprise-login__role-btn::after {
    content: '\203A';
    position: absolute;
    right: 1rem;
    font-size: 1.4rem;
    color: var(--snappy-gray-300);
    transition: color 0.2s, transform 0.2s;
}

.enterprise-login__role-btn:hover::after {
    color: var(--snappy-brand-primary);
    transform: translateX(2px);
}

/* ==========================================================================
   Form Sections (shown/hidden via JS)
   ========================================================================== */

.enterprise-login__section {
    display: none;
}

.enterprise-login__section--active {
    display: block;
    animation: sectionFadeIn 0.3s ease both;
}

@keyframes sectionFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Form header with back button */
.enterprise-login__form-header {
    display: flex;
    align-items: center;
    margin-bottom: 1.25rem;
}

.enterprise-login__back-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--snappy-radius-sm);
    background: var(--snappy-gray-50);
    color: var(--snappy-gray-700);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: background 0.2s, color 0.2s;
    flex-shrink: 0;
}

.enterprise-login__back-btn:hover {
    background: var(--snappy-gray-100);
    color: var(--snappy-brand-primary-dark);
}

.enterprise-login__form-title {
    flex: 1;
    font-size: 1.15rem;
    font-weight: var(--snappy-font-weight-bold);
    color: var(--snappy-brand-primary-dark);
    margin: 0;
    text-align: center;
    padding-right: 32px; /* Balance the back button width */
}

/* Code inputs */
.enterprise-login .auth-form input[data-code-input] {
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: var(--snappy-font-weight-semibold);
    font-size: 1.05rem;
}

/* Success message styling — hidden when empty */
.enterprise-login .auth-success {
    background: rgba(6, 167, 125, 0.08);
    border-radius: 0.625rem;
    padding: 0.875rem;
    text-align: center;
    line-height: 1.5;
}

.enterprise-login .auth-success:empty {
    display: none;
}

/* Loading state on submit buttons */
.enterprise-login .auth-form button[type="submit"].loading {
    pointer-events: none;
    opacity: 0.7;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.enterprise-login__footer {
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--snappy-gray-100);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.enterprise-login__footer p {
    font-size: 0.8rem;
    color: var(--snappy-gray-500);
    margin: 0;
}

.enterprise-login__footer a {
    color: var(--snappy-brand-primary);
    text-decoration: none;
    font-weight: var(--snappy-font-weight-semibold);
}

.enterprise-login__footer a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   Responsive — matches family app breakpoints (768 / 600 / 480 / 360)
   No mobile gate for login page — forms work fine on phones.
   ========================================================================== */

/* Tablet and below: card stretches wider */
@media (max-width: 768px) {
    .enterprise-login {
        padding: 1.25rem;
    }

    .enterprise-login__card {
        max-width: 400px;
    }
}

/* Small tablet / large phone */
@media (max-width: 600px) {
    .enterprise-login {
        padding: var(--snappy-space-4);
        /* Allow scroll when forms are taller than viewport (e.g. teacher signup) */
        height: auto;
        min-height: 100vh;
        overflow-y: auto;
    }

    html.enterprise-page,
    html.enterprise-page body {
        overflow: auto;
    }

    .enterprise-login__card {
        padding: 2rem 1.75rem;
        border-radius: 1.25rem;
        max-width: none;
        width: 100%;
    }

    .enterprise-login__subtitle {
        margin-bottom: 1.5rem;
    }
}

/* Phone */
@media (max-width: 480px) {
    .enterprise-login {
        padding: 0;
        align-items: flex-start;
    }

    .enterprise-login__card {
        padding: 2rem 1.5rem;
        border-radius: 0;
        box-shadow: none;
        min-height: 100vh;
    }

    .enterprise-login__logo {
        width: 64px;
    }

    .enterprise-login__brand {
        font-size: 1.2rem;
    }

    .enterprise-login__role-btn {
        padding: 0.75rem 1rem;
    }

    .enterprise-login__role-icon {
        width: 32px;
        height: 32px;
    }

    .enterprise-login__form-title {
        font-size: 1.05rem;
    }
}

/* Very small phone */
@media (max-width: 360px) {
    .enterprise-login__card {
        padding: 1.5rem 1.25rem;
    }

    .enterprise-login__brand {
        font-size: 1.1rem;
    }

    .enterprise-login__role-btn {
        padding: 0.625rem 0.875rem;
        font-size: 0.925rem;
    }

    .enterprise-login__role-desc {
        font-size: 0.7rem;
    }

    .enterprise-login__footer {
        margin-top: 1.25rem;
    }

    .enterprise-login__footer p {
        font-size: 0.75rem;
    }
}


/* ==========================================================================
   Password Requirements Checklist
   ========================================================================== */

.password-requirements {
    list-style: none;
    padding: 0;
    margin: 0.25rem 0 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
}

.password-requirements li {
    font-size: 0.72rem;
    color: var(--snappy-gray-500, #8C919F);
    position: relative;
    padding-left: 1rem;
}

.password-requirements li::before {
    content: '○';
    position: absolute;
    left: 0;
    font-size: 0.6rem;
    line-height: 1.4;
}

.password-requirements li.met {
    color: var(--snappy-success, #06A77D);
}

.password-requirements li.met::before {
    content: '✓';
}


/* ==========================================================================
   Contact Sales Form
   — renders inside the shared snappyFormPrompt modal chrome (see
     enterprise-notify.css). Only the form-field styles live here; modal
     backdrop / card / buttons / scroll-lock come from .snappy-modal-*.
   ========================================================================== */

.contact-sales-form__intro {
    font-size: 0.925rem;
    color: var(--snappy-gray-700);
    margin: 0 0 1.25rem;
    line-height: 1.5;
}

.contact-sales-form__required-note {
    color: var(--snappy-gray-500);
    font-size: 0.825rem;
    white-space: nowrap;
}

.contact-sales-form {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.contact-sales-form__field {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    text-align: left;
}

.contact-sales-form__label {
    font-size: 0.8rem;
    font-weight: var(--snappy-font-weight-semibold);
    color: var(--snappy-gray-700);
    letter-spacing: 0.01em;
}

.contact-sales-form input[type="text"],
.contact-sales-form input[type="email"],
.contact-sales-form input[type="tel"],
.contact-sales-form select,
.contact-sales-form textarea {
    width: 100%;
    padding: 0.75rem 0.875rem;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--snappy-gray-900);
    background: var(--snappy-white);
    border: 2px solid var(--snappy-gray-300);
    border-radius: 0.625rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    box-sizing: border-box;
}

.contact-sales-form textarea {
    resize: vertical;
    min-height: 96px;
    line-height: 1.5;
    font-family: inherit;
}

.contact-sales-form select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%235E6373'%3E%3Cpath d='M5.5 7.5l4.5 4.5 4.5-4.5' stroke='%235E6373' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 16px;
    padding-right: 2.25rem;
    cursor: pointer;
}

.contact-sales-form input:focus-visible,
.contact-sales-form select:focus-visible,
.contact-sales-form textarea:focus-visible {
    outline: none;
    border-color: var(--snappy-brand-primary);
    box-shadow: 0 0 0 3px var(--snappy-brand-primary-very-light);
}

.contact-sales-form input:invalid:not(:placeholder-shown),
.contact-sales-form select:invalid,
.contact-sales-form textarea:invalid:not(:placeholder-shown) {
    border-color: var(--snappy-error);
}

.contact-sales-form input::placeholder,
.contact-sales-form textarea::placeholder {
    color: var(--snappy-gray-500);
}

.contact-sales-form__row {
    display: grid;
    gap: 0.625rem;
}

.contact-sales-form__row--phone {
    grid-template-columns: 9.25rem 1fr;
}

.contact-sales-form__row--two {
    grid-template-columns: 1fr 1fr;
    gap: 0.875rem;
}

.contact-sales-form__hint {
    font-size: 0.75rem;
    color: var(--snappy-gray-500);
    margin-top: 0.125rem;
}

@media (max-width: 520px) {
    .contact-sales-form__row--phone {
        grid-template-columns: 7.5rem 1fr;
    }

    .contact-sales-form__row--two {
        grid-template-columns: 1fr;
    }
}
