/* ============================================================================
   USER DRAWER - Authentication & Profile Management Styles
   ============================================================================ */

/* Drawer Container */
.user-drawer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: calc(100% - 7rem);
    z-index: 999;
    pointer-events: none;
}

.user-drawer.active {
    pointer-events: auto;
}

/* Backdrop */
.user-drawer-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0);
    pointer-events: none;
    transition: background 0.3s ease;
    z-index: 0;
}

.user-drawer.active .user-drawer-backdrop {
    background: rgba(0, 0, 0, 0.5);
    pointer-events: auto;
}

/* Drawer Content */
.user-drawer-content {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 100%;
    background: #5839c7;
    border-top-left-radius: 1rem;
    border-top-right-radius: 1rem;
    box-shadow: 0 -0.25rem 1.5rem rgba(0, 0, 0, 0.25);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1;
}

.user-drawer.active .user-drawer-content {
    transform: translateY(-5rem);
}

/* Header */
.user-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 0.0625rem solid rgba(255, 255, 255, 0.15);
    flex-shrink: 0;
}

.user-drawer-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: #ffffff;
}

.user-drawer-close {
    background: none;
    border: none;
    font-size: 2rem;
    line-height: 1;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.375rem;
    transition: all 0.2s;
}

.user-drawer-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

/* Body */
.user-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    /* Modern scrollbar styling (Firefox) */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) rgba(255, 255, 255, 0.05);
}

/* Webkit scrollbar styling (Chrome, Safari, Edge) */
.user-drawer-body::-webkit-scrollbar {
    width: 0.5rem;
}

.user-drawer-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 0.25rem;
}

.user-drawer-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 0.25rem;
    transition: background 0.2s ease;
}

.user-drawer-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* Panel States */
.panel-state {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(0.625rem);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================================
   AUTH FORMS - Login & Register
   ============================================================================ */

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.auth-form h4 {
    margin: 0 0 1.5rem 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #ffffff;
}

/* Form Groups */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.625rem 0.75rem;
    font-size: 0.875rem;
    border: 0.0625rem solid rgba(255, 255, 255, 0.2);
    border-radius: 0.375rem;
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    transition: all 0.2s;
    font-family: inherit;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 0 0.1875rem rgba(255, 255, 255, 0.1);
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
}

.form-group textarea {
    resize: vertical;
    min-height: 5rem;
}

/* Select dropdown options */
.form-group select option {
    background: #4e31ba;
    color: #ffffff;
}

/* Form Error */
.form-error {
    display: none;
    padding: 0.75rem;
    margin-bottom: 1rem;
    background: #fef2f2;
    border: 0.0625rem solid #fecaca;
    border-radius: 0.375rem;
    color: #dc2626;
    font-size: 0.875rem;
}

.form-error.active {
    display: block;
}

/* Buttons */
.btn {
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: inherit;
}

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-primary:active {
    background: #1d4ed8;
}

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
}

.btn-secondary:hover {
    background: #e5e7eb;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Button Loading State */
.btn .btn-loading {
    display: none;
}

.btn.loading .btn-text {
    display: none;
}

.btn.loading .btn-loading {
    display: inline;
}

/* Form Footer */
.form-footer {
    margin-top: 1.25rem;
    text-align: center;
    padding-top: 1.25rem;
    border-top: 0.0625rem solid rgba(255, 255, 255, 0.15);
}

.form-footer p {
    margin: 0;
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.7);
}

.form-footer a {
    color: #93c5fd;
    text-decoration: none;
    font-weight: 500;
}

.form-footer a:hover {
    text-decoration: underline;
}

/* ============================================================================
   USER PROFILE - Logged In State
   ============================================================================ */

.user-profile-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 0.75rem;
    margin-bottom: 1.5rem;
}

.user-avatar-large {
    width: 3.75rem;
    height: 3.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    flex-shrink: 0;
}

.user-avatar-large img {
    width: 100%;
    background: transparent;
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-name-large {
    font-size: 1.125rem;
    font-weight: 600;
    color: white;
    margin-bottom: 0.25rem;
}

.user-email {
    font-size: 0.8125rem;
    color: rgba(255, 255, 255, 0.8);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================================================
   AVATAR UPLOAD SECTION
   ============================================================================ */

.avatar-upload-section {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 0.625rem;
}

.avatar-upload-section #avatarUploadForm {
    margin-top: 1rem;
}

.avatar-upload-section .form-group {
    margin-bottom: 1rem;
}

.avatar-upload-section input[type="file"] {
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.15);
    border: 0.125rem dashed rgba(255, 255, 255, 0.3);
    cursor: pointer;
}

.avatar-upload-section input[type="file"]:hover {
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.2);
}

.avatar-preview {
    margin: 1rem 0;
    text-align: center;
}

.avatar-preview img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 0.5rem;
    border: 0.125rem solid rgba(255, 255, 255, 0.3);
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

.form-actions .btn {
    flex: 0 0 auto;
}

/* ============================================================================
   BALANCE DISPLAY
   ============================================================================ */

.balance-display {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.balance-item {
    background: rgba(255, 255, 255, 0.1);
    border: 0.0625rem solid rgba(255, 255, 255, 0.15);
    border-radius: 0.625rem;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.balance-icon {
    font-size: 1.75rem;
}

.balance-info {
    flex: 1;
}

.balance-label {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 0.25rem;
}

.balance-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: #ffffff;
}

/* ============================================================================
   ACTIVITY LOG LINK
   ============================================================================ */

.activity-log-link {
    margin-bottom: 1.5rem;
}

.activity-log-link .action-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 0.0625rem solid rgba(255, 255, 255, 0.15);
    border-radius: 0.625rem;
    text-decoration: none;
    color: #ffffff;
    transition: all 0.2s;
}

.activity-log-link .action-link:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateX(0.25rem);
}

.activity-log-link .action-icon {
    font-size: 1.5rem;
}

.activity-log-link .action-label {
    font-size: 0.9375rem;
    font-weight: 500;
}

/* ============================================================================
   PERSONA SECTION
   ============================================================================ */

.persona-section {
    margin-bottom: 1.5rem;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.section-header h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #ffffff;
}

.persona-hint {
    background: rgba(255, 255, 255, 0.1);
    border-left: 3px solid #93c5fd;
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 0.5rem;
}

.persona-hint p {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.9);
}

.persona-hint strong {
    color: #ffffff;
    font-weight: 600;
}

.persona-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.persona-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 0.125rem solid rgba(255, 255, 255, 0.15);
    border-radius: 0.5rem;
    transition: all 0.2s;
    position: relative;
}

.persona-item:hover {
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.05);
}

.persona-item.active {
    border-color: #93c5fd;
    background: rgba(147, 197, 253, 0.15);
}

.persona-item-clickable {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    cursor: pointer;
    min-width: 0;
}

.persona-avatar {
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.persona-avatar img {
    width: 100%;
}

.persona-info {
    flex: 1;
    min-width: 0;
}

.persona-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: #ffffff;
    margin-bottom: 0.125rem;
}

.persona-alias {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
}

.persona-status {
    font-size: 0.7rem;
    color: #93c5fd;
    font-style: italic;
    margin-top: 0.2rem;
}

.persona-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.persona-check {
    font-size: 1.125rem;
    color: #93c5fd;
    opacity: 0;
    transition: opacity 0.2s;
    width: 1.5rem;
    text-align: center;
}

.persona-item.active .persona-check {
    opacity: 1;
}

.persona-delete {
    display: none;
    width: 2rem;
    height: 2rem;
    border-radius: 0.375rem;
    background: #fee;
    border: 0.0625rem solid #fcc;
    color: #dc2626;
    font-size: 1.25rem;
    font-weight: bold;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.persona-item:hover .persona-delete {
    display: flex;
}

.persona-delete:hover {
    background: #dc2626;
    border-color: #dc2626;
    color: white;
    transform: scale(1.1);
}

.persona-item.is-main .persona-delete {
    display: none !important;
}

/* Create Persona Form */
.create-persona-form {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 0.0625rem solid rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
}

.create-persona-form h4 {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: #ffffff;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.form-actions .btn {
    flex: 1;
}

/* ============================================================================
   USER ACTIONS
   ============================================================================ */

.user-actions {
    padding-top: 1.5rem;
    border-top: 0.0625rem solid rgba(255, 255, 255, 0.15);
}

.action-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 0.5rem;
    transition: all 0.2s;
    text-align: left;
}

.action-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.action-icon {
    font-size: 1.25rem;
}

.action-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
}

.action-item.logout {
    color: #fca5a5;
}

.action-item.logout .action-label {
    color: #fca5a5;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

/* Mobile: Between header and footer */
@media (max-width: 639px) {
    .user-drawer {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        width: 100%;
        height: calc(100vh - 6rem - 7rem);
        z-index: 2500;
    }

    .user-drawer-backdrop {
        top: 0;
        height: 100%;
    }

    .user-drawer-content {
        max-height: 100%;
        border-top-left-radius: 0;
        border-top-right-radius: 0;
    }
}

/* Tablet: Similar to desktop but full width */
@media (min-width: 640px) and (max-width: 1279px) {
    .user-drawer {
        bottom: 0;
        height: calc(100% - 7rem);
    }

    .user-drawer-backdrop {
        top: 0;
        height: 100%;
    }
}