/* ==========================================
   MangaStudio - Authentication Pages CSS
   Apple Minimalist Design System
   ========================================== */

/* Auth Page Container */
.auth-page {
    min-height: 100vh;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.auth-container {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Logo Section */
.auth-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
}

.auth-logo svg {
    flex-shrink: 0;
}

.auth-logo-text {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

/* Auth Card */
.auth-card {
    width: 100%;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    padding: 40px;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.08);
}

.auth-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 8px;
    letter-spacing: -0.3px;
}

.auth-subtitle {
    font-size: 15px;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 32px;
    line-height: 1.5;
}

/* Flash Messages */
.flash-message {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.5;
}

.flash-success {
    background: rgba(52, 199, 89, 0.12);
    color: #248a3d;
    border: 1px solid rgba(52, 199, 89, 0.2);
}

.flash-error,
.flash-danger {
    background: rgba(255, 59, 48, 0.12);
    color: #d70015;
    border: 1px solid rgba(255, 59, 48, 0.2);
}

.flash-info,
.flash-warning {
    background: rgba(0, 113, 227, 0.12);
    color: #0062cc;
    border: 1px solid rgba(0, 113, 227, 0.2);
}

/* Form Styles */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-input {
    width: 100%;
    height: 48px;
    padding: 0 16px;
    font-size: 16px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    outline: none;
}

.form-input::placeholder {
    color: var(--text-tertiary);
}

.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

.form-input:hover:not(:focus) {
    border-color: var(--text-tertiary);
}

/* Input Error State */
.form-input.input-error {
    border-color: #ff3b30;
    background: rgba(255, 59, 48, 0.04);
}

.form-input.input-error:focus {
    box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.1);
}

/* Input Warning State (passwords don't match while typing) */
.form-input.input-warning {
    border-color: #ff9500;
}

.form-error {
    font-size: 13px;
    color: #ff3b30;
    margin-top: 4px;
}

.form-hint {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: -4px;
}

/* Password Input Wrapper */
.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input-wrapper .form-input {
    padding-right: 48px;
}

.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.password-toggle:hover {
    color: var(--text-secondary);
}

.password-toggle:focus {
    outline: none;
    color: var(--accent);
}

/* Checkbox Styles */
.form-group-inline {
    display: flex;
    align-items: center;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.checkbox-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.checkbox-custom {
    width: 20px;
    height: 20px;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.checkbox-custom::after {
    content: '';
    width: 10px;
    height: 6px;
    border-left: 2px solid white;
    border-bottom: 2px solid white;
    transform: rotate(-45deg) scale(0);
    transition: transform 0.2s ease;
    margin-top: -2px;
}

.checkbox-input:checked + .checkbox-custom {
    background: var(--accent);
    border-color: var(--accent);
}

.checkbox-input:checked + .checkbox-custom::after {
    transform: rotate(-45deg) scale(1);
}

.checkbox-input:focus + .checkbox-custom {
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

.checkbox-text {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Primary Button */
.btn-primary {
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: white;
    font-size: 16px;
    font-weight: 500;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
    text-decoration: none;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-primary:visited {
    color: white;
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.3);
}

.btn-primary:disabled {
    background: var(--text-tertiary);
    cursor: not-allowed;
    transform: none;
}

.btn-full {
    width: 100%;
}

/* Auth Footer */
.auth-footer {
    margin-top: 24px;
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
}

.auth-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

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

/* Hide navbar and progress bar on auth pages */
.auth-page ~ .navbar,
body:has(.auth-page) .navbar,
body:has(.auth-page) .progress-bar {
    display: none;
}

/* Responsive Adjustments */
@media (max-width: 480px) {
    .auth-page {
        padding: 24px 16px;
    }

    .auth-card {
        padding: 32px 24px;
    }

    .auth-title {
        font-size: 22px;
    }

    .auth-subtitle {
        font-size: 14px;
    }

    .auth-logo-text {
        font-size: 20px;
    }
}

/* Animation for form appearing */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-card {
    animation: slideUp 0.4s ease forwards;
}

.auth-logo {
    animation: slideUp 0.4s ease forwards;
    animation-delay: 0.1s;
    opacity: 0;
}

.auth-footer {
    animation: slideUp 0.4s ease forwards;
    animation-delay: 0.2s;
    opacity: 0;
}

/* ==========================================
   Loading State Styles
   ========================================== */

/* Button Loading State */
.btn-primary.btn-loading {
    position: relative;
    cursor: wait;
    background: var(--text-tertiary);
}

.btn-primary.btn-loading:hover {
    background: var(--text-tertiary);
    transform: none;
}

/* Loading Spinner */
.btn-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

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

/* Field Error State (alternative class name) */
.form-input.field-error {
    border-color: #ff3b30;
    background: rgba(255, 59, 48, 0.04);
}

.form-input.field-error:focus {
    box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.1);
}

/* Error Message (alternative class name for auth.js) */
.auth-form .error-message {
    font-size: 13px;
    color: #ff3b30;
    margin-top: 4px;
    padding: 0;
    display: block;
    text-align: left;
    align-items: initial;
    justify-content: initial;
}

/* Disabled Form State */
.auth-form input:disabled,
.auth-form button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.auth-form input:disabled {
    background: var(--bg-secondary);
}

/* Focus outline for accessibility */
.form-input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Screen reader only class */
.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;
}
