@import url('https://fonts.googleapis.com/icon?family=Material+Icons');
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap');
@import url('css/unauthorized.css');

:root {
    color-scheme: dark;
    --color-bg: #050b18;
    --color-panel: #0f172a;
    --color-text: #e2e8f0;
    --color-muted: #94a3b8;
    --color-border: #1f2a3e;
    --color-accent: #60a5fa;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    letter-spacing: 0.01em;
    -webkit-font-smoothing: antialiased;
}

body {
    display: flex;
    flex-direction: column;
}

a {
    color: var(--color-accent);
}

a:hover,
a:focus-visible {
    color: #93c5fd;
}

/* Shared auth form styles */
.auth-card .auth-form {
    margin-bottom: 1.5rem !important;
}

.auth-card .auth-form .form-row:last-of-type {
    margin-bottom: 0 !important;
}

.form-row {
    gap: .5rem;
}

.field-label {
    font-size: .95rem;
    color: var(--color-muted);
    font-weight: 600;
    display: block;
    margin-bottom: .50rem;
    text-align: left;
}

.input-wrapper {
    position: relative;
    width: 100% !important;
}

button,
input,
textarea {
    font: inherit;
}

button {
    background: transparent;
    border: none;
}

button:focus-visible,
a:focus-visible {
    outline: 2px solid rgba(96, 165, 250, 0.55);
    outline-offset: 2px;
    border-radius: 0.5rem;
}

::-moz-selection {
    background: rgba(96, 165, 250, 0.35);
    color: var(--color-text);
}

::selection {
    background: rgba(96, 165, 250, 0.35);
    color: var(--color-text);
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Auth redirect styles */
.auth-redirect {
    min-height: 100vh;
    width: 100vw;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    background: var(--color-bg);
    color: var(--color-text);
}

.auth-redirect p {
    font-size: 1.125rem;
    margin-bottom: 2rem;
    color: var(--color-muted);
}

.auth-redirect .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    border: none;
    background: var(--color-accent);
    color: white;
}

.auth-redirect .btn:hover {
    background: #60a5fa;
}

/* Login form input styles following app color scheme */
input.form-input,
.auth-card input {
    background-color: var(--color-panel) !important;
    border: 1.5px solid var(--color-border) !important;
    color: var(--color-text) !important;
    border-radius: 0.75rem !important;
    width: 100% !important;
    padding: 0.75rem 1rem !important;
    font-size: 1rem !important;
    transition: border-color 0.2s, box-shadow 0.2s !important;
}

input.form-input:focus,
.auth-card input:focus {
    outline: none !important;
    border-color: var(--color-accent) !important;
    box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.25) !important;
}

input.form-input:hover,
.auth-card input:hover {
    border-color: var(--color-accent) !important;
}

/* Modern error message styling with enhanced UX */
.error-message {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.12), rgba(239, 68, 68, 0.06));
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 0.75rem;
    padding: 1.25rem 1.5rem 1.25rem 1.5rem;
    margin: 1.5rem 0 2rem;
    color: #dc2626;
    font-size: 0.875rem;
    font-weight: 500;
    text-align: center;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.15), 0 1px 3px rgba(239, 68, 68, 0.1);
    position: relative;
    overflow: hidden;
    animation: slideInError 0.3s ease-out;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 3rem;
    backdrop-filter: blur(8px);
}

.error-message .error-icon {
    position: absolute;
    left: 1.25rem;
    top: 1.25rem;
    color: #dc2626;
    font-size: 1.25rem;
    opacity: 0.9;
}

.error-message .error-content {
    flex: 1;
    padding-right: 0.5rem;
    text-align: center;
}

.error-message .error-dismiss {
    background: none;
    border: none;
    color: #dc2626;
    cursor: pointer;
    padding: 0.375rem;
    border-radius: 0.375rem;
    opacity: 0.7;
    transition: all 0.2s ease;
    font-size: 1.125rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    margin-top: 0.125rem;
}

.error-message .error-dismiss:hover {
    opacity: 1;
    background-color: rgba(220, 38, 38, 0.15);
    transform: scale(1.05);
}

.error-message .error-dismiss:focus {
    outline: 2px solid #dc2626;
    outline-offset: 2px;
}

/* Field validation error styling with enhanced UX */
.field-error {
    color: #dc2626;
    font-size: 0.8125rem;
    margin: .2rem 0 0;
    font-weight: 500;
    display: block;
    line-height: 1.3;
    animation: fadeInError 0.2s ease-out;
    position: static;
    overflow: visible;
}

/* Validation summary styling */
.validation-errors {
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.12), rgba(220, 38, 38, 0.06));
    border: 1px solid rgba(220, 38, 38, 0.3);
    border-radius: 0.75rem;
    padding: 1rem 1.25rem 1rem 2.75rem;
    margin-bottom: 1.5rem;
    color: #dc2626;
    font-size: 0.8125rem;
    font-weight: 500;
    animation: slideInError 0.3s ease-out;
    position: relative;
    backdrop-filter: blur(8px);
}

.validation-errors::before {
    content: 'error';
    position: absolute;
    left: 1rem;
    top: 1rem;
    font-family: 'Material Icons';
    font-size: 1.125rem;
    opacity: 0.9;
    color: #dc2626;
}

.validation-errors ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.validation-errors li {
    margin-bottom: 0.25rem;
}

.validation-errors li:last-child {
    margin-bottom: 0;
}

/* Input field error states */
.form-input.invalid,
.input-wrapper.invalid input {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.2) !important;
    background-color: rgba(220, 38, 38, 0.03) !important;
}

.form-input.invalid:focus,
.input-wrapper.invalid input:focus {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.25) !important;
}

/* Success states for valid inputs */
/* disabled per request: no green glow on valid inputs */

/* Animations */
@keyframes slideInError {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.error-shake {
    animation: shake 0.5s ease-in-out;
}

/* Loading state for forms */
.form-row.loading input,
.form-group.loading input {
    opacity: 0.7;
    pointer-events: none;
}

.auth-container {
    min-height: 100vh;
    width: 100vw;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.auth-container .auth-card {
    text-align: center;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: rgba(15, 23, 42, 0.88);
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 1rem;
    box-shadow: 0 18px 42px rgba(15, 23, 42, .65);
    padding: 2rem;
    backdrop-filter: blur(16px);
}

.auth-card--center {
    text-align: center;
}

.auth-card--center .auth-header {
    margin-bottom: 0;
}

.auth-card--center .auth-title {
    margin-bottom: .75rem;
}

.auth-card--center .auth-subtitle {
    margin-top: 0;
}

.auth-header {
    text-align: center;
    margin: 0 0 1.2rem 0;
}

.auth-title {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--color-text);
}

.auth-subtitle {
    color: var(--color-muted);
    margin: .5rem 0 0;
    font-size: .92rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.1rem;
    border-top: 1px solid rgba(148, 163, 184, 0.12);
    color: var(--color-muted);
}

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

.auth-link:hover {
    color: #93c5fd;
    text-decoration: underline;
}

.auth-link-small {
    font-size: .85rem;
    color: var(--color-accent);
    text-decoration: none;
}

.auth-link-small:hover {
    color: #93c5fd;
    text-decoration: underline;
}

.remember-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: -.25rem;
}

.remember-label {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    font-size: .9rem;
    color: var(--color-muted);
}

.remember-label input {
    accent-color: var(--color-accent);
}

.form-actions {
    margin-top: .5rem;
    display: flex;
    justify-content: center;
}

.remember-row {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 1.5rem;
}

.remember-label {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    color: var(--color-muted);
    font-size: .95rem;
    font-weight: 500;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.remember-label input[type="checkbox"] {
    margin: 0;
    width: 1.1rem;
    height: 1.1rem;
    outline: none;
}

.remember-label input[type="checkbox"]:focus,
.remember-label input[type="checkbox"]:focus-visible {
    outline: none;
    box-shadow: none;
}

.remember-label span {
    user-select: none;
    line-height: 1.1;
}

.auth-form .btn {
    width: 100%;
    min-width: unset;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: 1rem 2rem;
    border-radius: 1rem;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: transform .15s, box-shadow .2s, background .2s;
    min-width: 160px;
}

.btn-primary {
    background: var(--color-accent);
    color: #fff;
    box-shadow: 0 6px 22px rgba(59, 130, 246, .28);
}

.btn-primary:hover {
    transform: translateY(-2px);
    background: #60a5fa;
    box-shadow: 0 10px 28px rgba(59, 130, 246, .34);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 4px 16px rgba(59, 130, 246, .28);
}

.btn-secondary {
    background: rgba(96, 165, 250, .12);
    color: var(--color-text);
    border: 1px solid rgba(96, 165, 250, .35);
}

.btn-secondary:hover {
    background: rgba(96, 165, 250, .22);
}

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

.spinner {
    width: 1rem;
    height: 1rem;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.external-logins {
    margin-top: 1.5rem;
    text-align: center;
    color: var(--color-muted);
    font-size: .9rem;
}

.external-logins-form {
    margin-top: 1rem;
    display: flex;
    gap: .75rem;
    flex-wrap: wrap;
    justify-content: center;
}

.external-logins-form .btn {
    min-width: 160px;
}
/* Improved responsive error handling */
@media (max-width: 640px) {
    .error-message {
        padding: 1rem 1.25rem 1rem 3rem;
        font-size: 0.8125rem;
        margin: 1.25rem 0 0.875rem;
    }

    .error-message .error-icon {
        left: 1rem;
        top: 1rem;
        font-size: 1.125rem;
    }

    .error-message .error-dismiss {
        width: 1.5rem;
        height: 1.5rem;
        padding: 0.25rem;
    }

    .validation-errors {
        padding: 0.875rem 1rem 0.875rem 2.5rem;
        font-size: 0.8125rem;
        margin-bottom: 1.25rem;
    }

    .validation-errors::before {
        left: 0.875rem;
        top: 0.875rem;
        font-size: 1rem;
    }

    .field-error {
        font-size: 0.75rem;
        margin-top: 0.375rem;
        padding-left: 1.25rem;
    }

    .field-error::before {
        font-size: 0.75rem;
        top: 0.125rem;
    }
}