/* ==========================================================================
   ORESS Authentication Base Styles
   Minimal Modern Design System
   ========================================================================== */

/* ==========================================================================
   CSS Custom Properties (Variables)
   ========================================================================== */
:root {
    /* Primary Color Palette */
    --primary: #0ea5e9;
    --primary-dark: #0284c7;
    --primary-light: #38bdf8;
    --primary-50: #f0f9ff;
    --primary-100: #e0f2fe;

    /* Accent Colors */
    --accent: #8b5cf6;
    --accent-dark: #7c3aed;
    --accent-light: #a78bfa;

    /* Neutral Colors */
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    /* Semantic Colors */
    --success: #10b981;
    --success-light: #d1fae5;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;

    /* Glass Effects */
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    --backdrop-blur: blur(20px);

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-display: 'Poppins', var(--font-sans);

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Border Radius */
    --radius-sm: 6px;
    --radius: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
}

/* ==========================================================================
   Reset & Base Styles
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f97316 100%);
    background-size: 200% 200%;
    animation: gradientFlow 15s ease infinite;
    min-height: 100vh;
    color: var(--gray-800);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

@keyframes gradientFlow {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* Subtle animated background shapes */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: floatBg 25s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: '';
    position: fixed;
    bottom: -50%;
    left: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 70%);
    animation: floatBg 30s ease-in-out infinite reverse;
    pointer-events: none;
    z-index: 0;
}

@keyframes floatBg {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(30px, -30px); }
}

/* ==========================================================================
   Typography
   ========================================================================== */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 600;
    line-height: 1.3;
    color: var(--gray-900);
}

/* ==========================================================================
   Shared Alert Styles
   ========================================================================== */
.alert {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 1.25rem;
    animation: slideIn 0.3s ease-out;
}

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

.alert-success {
    background: var(--success-light);
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-danger {
    background: var(--danger-light);
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background: var(--warning-light);
    color: #92400e;
    border: 1px solid #fde68a;
}

.alert i {
    font-size: 1rem;
    flex-shrink: 0;
}

/* Inline action inside an alert (e.g. the resend-verification CTA on login). */
.alert .resend-link {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
}

.alert .resend-link:disabled {
    opacity: 0.6;
    cursor: default;
}

/* ==========================================================================
   Shared Form Styles
   ========================================================================== */
.error-message {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--danger);
    font-size: 0.8rem;
    font-weight: 500;
    margin-top: 0.375rem;
    padding-left: 0.25rem;
    animation: slideIn 0.2s ease-out;
}

.error-message i {
    font-size: 0.75rem;
}

.field-error {
    border-color: var(--danger) !important;
}

.field-error:focus-within {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
}

/* ==========================================================================
   Loading States
   ========================================================================== */
.loading-icon {
    display: none;
}

.btn-loading .loading-icon {
    display: inline-block;
    animation: spin 0.8s linear infinite;
}

.btn-loading .btn-text {
    opacity: 0.7;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   Shared Auth Page Layout
   ========================================================================== */

/* Main Container */
.auth-wrapper {
    min-height: 100vh;
    min-height: 100dvh; /* mobile browser chrome — keeps the card truly centred */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    position: relative;
    z-index: 1;
}

/* Auth Card */
.auth-card {
    width: 100%;
    max-width: 420px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    animation: cardEnter 0.5s ease-out;
}

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

/* ==========================================================================
   Card Header
   ========================================================================== */
.auth-header {
    padding: 2.5rem 2rem 2rem;
    text-align: center;
}

.auth-logo {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.25rem;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}

.auth-logo i {
    font-size: 1.5rem;
    color: white;
}

.auth-title {
    font-family: var(--font-display);
    font-size: 1.625rem;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0 0 0.375rem;
    letter-spacing: -0.02em;
}

.auth-subtitle {
    color: var(--gray-500);
    font-size: 0.9rem;
    margin: 0;
}

/* ==========================================================================
   Card Body
   ========================================================================== */
.auth-body {
    padding: 0.5rem 2rem 2rem;
}

/* ==========================================================================
   Form Fields
   ========================================================================== */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 1rem;
    color: var(--gray-400);
    font-size: 0.9375rem;
    pointer-events: none;
    transition: color var(--transition-base);
}

.form-input {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 2.75rem;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--gray-800);
    background: var(--gray-50);
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-md);
    outline: none;
    transition: all var(--transition-base);
}

.form-input::placeholder {
    color: var(--gray-400);
    font-weight: 400;
}

.form-input:hover {
    border-color: var(--gray-300);
    background: white;
}

.form-input:focus {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

.form-input:focus + .input-icon,
.input-wrapper:focus-within .input-icon {
    color: var(--primary);
}

/* Select styling */
select.form-input {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%2394a3b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.75rem center;
    background-repeat: no-repeat;
    background-size: 1.25em 1.25em;
    padding-right: 2.5rem;
}

/* Field hint */
.field-hint {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
    padding-left: 0.125rem;
}

/* ==========================================================================
   Checkbox Styles
   ========================================================================== */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--gray-600);
    user-select: none;
}

.checkbox-input {
    width: 1.125rem;
    height: 1.125rem;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: white;
    cursor: pointer;
    appearance: none;
    position: relative;
    transition: all var(--transition-fast);
}

.checkbox-input:checked {
    background: var(--primary);
    border-color: var(--primary);
}

.checkbox-input:checked::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 5px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-input:focus {
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}

.checkbox-label a {
    /* Same WCAG AA issue + fix as .auth-footer a (Phase 6.2). */
    color: #075985;
    text-decoration: none;
    font-weight: 500;
}

.checkbox-label a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   Submit Button
   ========================================================================== */
.btn-submit {
    width: 100%;
    padding: 0.9375rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.btn-submit::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(14, 165, 233, 0.35);
}

.btn-submit:hover::before {
    left: 100%;
}

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

.btn-submit:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* ==========================================================================
   Divider
   ========================================================================== */
.auth-divider {
    display: flex;
    align-items: center;
    margin: 1.75rem 0;
    color: var(--gray-400);
    font-size: 0.8125rem;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--gray-200);
}

.auth-divider span {
    padding: 0 1rem;
}

/* ==========================================================================
   Card Footer
   ========================================================================== */
.auth-footer {
    text-align: center;
    padding: 1.5rem 2rem;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-100);
}

.auth-footer p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--gray-600);
}

.auth-footer a {
    /* `--primary` (#0ea5e9) on the gray-50 footer fails WCAG AA at 2.64:1
       (Phase 6.2 axe). `--primary-dark` (#0284c7) still misses at 3.91:1
       — sky-800 #075985 lands at ~7:1, passing both AA and AAA. Hover goes
       a touch darker so the focus state remains visibly distinct. */
    color: #075985;
    font-weight: 600;
    text-decoration: none;
    transition: color var(--transition-fast);
}

.auth-footer a:hover {
    color: #0c4a6e;
    text-decoration: underline;
}

/* ==========================================================================
   Password Toggle
   ========================================================================== */
.password-toggle {
    position: absolute;
    right: 0.875rem;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.password-toggle:hover {
    color: var(--gray-600);
    background: var(--gray-100);
}

/* ==========================================================================
   Responsive Design - Base
   ========================================================================== */
@media (max-width: 600px) {
    /* The fixed corner brand (auth/base.html) collides with the card on
       phones - the card already carries the ORESS logo, so drop the corner
       one. !important because the link is positioned via inline styles. */
    .auth-brand-link {
        display: none !important;
    }
}

@media (max-width: 480px) {
    /* Stay vertically centred: the wrapper is min-height, so a card taller
       than the viewport simply grows it and the page scrolls — nothing clips. */
    .auth-wrapper {
        padding: 1rem;
    }

    .auth-card {
        border-radius: var(--radius-lg);
    }

    .auth-header {
        padding: 2rem 1.5rem 1.5rem;
    }

    .auth-logo {
        width: 48px;
        height: 48px;
    }

    .auth-logo i {
        font-size: 1.25rem;
    }

    .auth-title {
        font-size: 1.375rem;
    }

    .auth-body {
        padding: 0.5rem 1.5rem 1.5rem;
    }

    .auth-footer {
        padding: 1.25rem 1.5rem;
    }
}
