/*
 * ============================================================================
 * Authentication UI Styles
 * ============================================================================
 * Styles for the login/register modals, auth bar in MainLayout,
 * user menu dropdown, and mobile auth controls.
 * Uses the same CSS variables as the rest of the app (variables.css).
 * ============================================================================
 */

/* ============================================================================
 * AUTH BAR - Top-right strip rendered above page content
 * ============================================================================ */
.auth-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 6px 16px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-header);
    min-height: 40px;
    gap: 10px;
    position: relative;
}

.auth-bar-login-btn {
    padding: 6px 16px;
    font-size: 13px;
    border-radius: 4px;
    cursor: pointer;
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    border: none;
    transition: background-color 0.15s ease;
}

.auth-bar-login-btn:hover {
    background: var(--btn-primary-bg-hover);
}

.auth-guest-label {
    font-size: 13px;
    color: var(--text-secondary);
    opacity: 0.7;
}

/* ============================================================================
 * USER MENU - Signed-in state dropdown
 * ============================================================================ */
.auth-user-area {
    position: relative;
    display: flex;
    align-items: center;
    margin-left: auto; /* Push to the right side */
}

.auth-user-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    background: transparent;
    border: 1px solid var(--border-header);
    border-radius: 4px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 13px;
    transition: border-color 0.15s ease;
}

.auth-user-btn:hover {
    border-color: var(--color-accent-blue);
    background: transparent;
}

.auth-user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--color-accent-blue);
    color: var(--btn-primary-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.auth-user-name {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.auth-user-caret {
    font-size: 10px;
    opacity: 0.7;
}

.auth-user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--bg-header);
    border: 1px solid var(--border-header);
    border-radius: 4px;
    min-width: 160px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 1100;
    overflow: hidden;
}

.auth-user-dropdown-info {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-header);
    font-size: 12px;
    color: var(--text-secondary);
}

.auth-user-dropdown-info .auth-dropdown-email {
    display: block;
    margin-top: 2px;
    opacity: 0.7;
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.auth-user-dropdown-info .auth-dropdown-plan {
    display: inline-block;
    margin-top: 4px;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    background: var(--color-accent-blue);
    color: var(--btn-primary-text);
}

.auth-dropdown-btn {
    width: 100%;
    padding: 10px 14px;
    background: transparent;
    border: none;
    border-radius: 0;
    color: var(--text-primary);
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.1s ease;
}

.auth-dropdown-btn:hover {
    background: var(--color-dark-grey);
}

.auth-dropdown-btn.destructive-text {
    color: #ef4444;
}

.auth-dropdown-btn.destructive-text:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* ============================================================================
 * AUTH MODAL EXTENSIONS - Builds on top of .modal-overlay / .modal-dialog
 * ============================================================================ */
.auth-modal-overlay {
    z-index: 1200;
}

.auth-modal-dialog {
    max-width: 420px;
}

/* ?? Field groups ?????????????????????????????????????????????????????? */
.auth-field-group {
    margin-bottom: 14px;
}

.auth-field-group label {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.auth-input {
    width: 100%;
    padding: 10px;
    font-size: 14px;
    border: 1px solid var(--border-header);
    border-radius: 4px;
    background: var(--bg-app);
    color: var(--text-header-title);
    box-sizing: border-box;
    transition: border-color 0.15s ease;
}

.auth-input:focus {
    outline: none;
    border-color: var(--color-accent-blue);
}

.auth-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.auth-field-error {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: #ef4444;
}

/* ?? Remember-me row ??????????????????????????????????????????????????? */
.auth-remember-row {
    margin-bottom: 16px;
}

.auth-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
}

.auth-checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--color-accent-blue);
    cursor: pointer;
}

/* ?? Modal buttons ????????????????????????????????????????????????????? */
.auth-modal-buttons {
    margin-top: 16px;
}

/* ?? Footer link row ??????????????????????????????????????????????????? */
.auth-footer {
    margin-top: 16px;
    text-align: center;
    font-size: 13px;
    color: var(--text-secondary);
}

.auth-footer a {
    color: var(--color-accent-blue);
    text-decoration: none;
    font-weight: 500;
}

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

/* ?? Prompt & error messages ??????????????????????????????????????????? */
.auth-prompt-message {
    margin-bottom: 14px;
    padding: 10px 12px;
    border-radius: 4px;
    font-size: 13px;
    color: var(--color-accent-blue);
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.25);
    line-height: 1.4;
}

.auth-error-message {
    margin-bottom: 14px;
    padding: 10px 12px;
    border-radius: 4px;
    font-size: 13px;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25);
    white-space: pre-line;
    line-height: 1.4;
}

/* ?? Spinner ??????????????????????????????????????????????????????????? */
.auth-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--btn-primary-text);
    border-radius: 50%;
    animation: auth-spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

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

/* ============================================================================
 * MOBILE OVERRIDES
 * ============================================================================ */
@media (max-width: 768px) {
    .auth-bar {
        padding: 4px 10px;
        min-height: 36px;
    }

    .auth-bar-login-btn {
        padding: 6px 12px;
        font-size: 12px;
    }

    .auth-user-name {
        display: none; /* Show avatar only on mobile */
    }

    .auth-user-btn {
        padding: 4px 8px;
    }

    .auth-user-dropdown {
        right: 0;
        min-width: 180px;
    }

    .auth-modal-dialog {
        max-width: calc(100% - 32px);
    }

    .auth-input {
        font-size: 16px; /* Prevent iOS zoom */
        padding: 12px;
    }
}

/* ============================================================================
 * MOBILE AUTH MENU - Auth controls integrated into mobile menu
 * ============================================================================ */
.mobile-auth-menu {
    display: none;
    flex-direction: column;
    gap: 8px;
    padding: 10px 0;
    border-top: 1px solid var(--border-header);
    border-bottom: 1px solid var(--border-header);
    background: var(--bg-header);
}

.mobile-auth-user-info {
    padding: 10px 14px;
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mobile-auth-plan {
    display: inline-block;
    width: fit-content;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    background: var(--color-accent-blue);
    color: var(--btn-primary-text);
}

.mobile-auth-login-btn,
.mobile-auth-register-btn,
.mobile-auth-logout-btn {
    padding: 10px 14px;
    margin: 0 10px;
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background-color 0.15s ease;
}

.mobile-auth-login-btn:hover,
.mobile-auth-register-btn:hover {
    background: var(--btn-primary-bg-hover);
}

.mobile-auth-logout-btn {
    margin: 0 10px;
    background: transparent;
    border: 1px solid var(--border-header);
    color: #ef4444;
}

.mobile-auth-logout-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
}

/* ============================================================================
 * DESKTOP: Hide mobile auth menu
 * ============================================================================ */
@media (min-width: 769px) {
    .mobile-auth-menu {
        display: none !important;
    }
}
