.page-wrapper {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.background-gradient {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(
            ellipse at top,
            rgba(139, 92, 246, 0.15) 0%,
            transparent 60%
        ),
        radial-gradient(
            ellipse at bottom right,
            rgba(59, 130, 246, 0.1) 0%,
            transparent 50%
        );
    z-index: 0;
    animation: gradientShift 10s ease infinite;
}

@keyframes gradientShift {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.content-container {
    position: relative;
    z-index: 10;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

.header-section {
    text-align: center;
    margin-bottom: 4rem;
    animation: fadeInDown 0.6s ease;
}

.page-title {
    font-size: 3.5rem;
    font-weight: 900;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #ffffff 0%, #a78bfa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.page-subtitle {
    font-size: 1.2rem;
    color: var(--color-text-secondary);
    font-weight: 500;
}

.users-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, 260px);
    gap: 2rem;
    margin-bottom: 3rem;
    animation: fadeInUp 0.8s ease;
    justify-content: center;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

.user-card {
    position: relative;
    aspect-ratio: 1;
    cursor: pointer;
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    background: var(--color-bg-elevated);
    border: 2px solid rgba(255, 255, 255, 0.05);
}

.user-card:hover {
    transform: translateY(-12px) scale(1.02);
    border-color: var(--color-primary);
    box-shadow: 0 20px 40px rgba(139, 92, 246, 0.3);
}

.user-card.has-password::after {
    content: "🔒";
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.7);
    padding: 0.4rem 0.7rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    z-index: 10;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.user-avatar {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e1e22 0%, #2a2a2f 100%);
    position: relative;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-avatar-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(
        135deg,
        rgba(139, 92, 246, 0.1) 0%,
        rgba(59, 130, 246, 0.05) 100%
    );
}

.user-avatar-placeholder svg {
    width: 50%;
    height: 50%;
    opacity: 0.3;
}

.user-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem 1.5rem;
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.95) 0%,
        rgba(0, 0, 0, 0.7) 50%,
        transparent 100%
    );
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.user-card:hover .user-info {
    transform: translateY(0);
}

.user-name {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-status {
    display: none;
}

.user-config-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition:
        opacity 0.3s,
        background 0.2s;
    z-index: 20;
}

.user-card:hover .user-config-btn {
    opacity: 1;
}

.user-config-btn:hover {
    background: var(--color-primary);
}

.btn-add-user {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    max-width: 400px;
    margin: 0 auto 2rem;
    padding: 1.2rem 2rem;
    background: rgba(139, 92, 246, 0.1);
    border: 2px dashed var(--color-primary);
    border-radius: 999px;
    color: var(--color-primary);
    font-weight: 700;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-add-user:hover {
    background: rgba(139, 92, 246, 0.2);
    transform: scale(1.05);
    box-shadow: 0 10px 30px var(--color-primary-glow);
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    position: relative;
    z-index: 10;
    background: var(--color-bg-elevated);
    border-radius: var(--radius-lg);
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: scaleIn 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.modal-large {
    max-width: 700px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.modal-header h2 {
    font-size: 1.8rem;
    font-weight: 800;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--color-text-secondary);
}

.form-group input[type="text"],
.form-group input[type="password"] {
    width: 100%;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    color: white;
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.2s;
}

.form-group input[type="text"]:focus,
.form-group input[type="password"]:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--color-primary);
    box-shadow: 0 0 15px var(--color-primary-glow);
    outline: none;
}

.password-toggle-wrapper {
    position: relative;
}

.password-toggle-btn {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.password-toggle-btn:hover {
    color: white;
}

.optional-label {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    font-weight: 400;
}

.avatar-upload-area {
    border: 2px dashed rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: rgba(255, 255, 255, 0.02);
}

.avatar-upload-area:hover {
    border-color: var(--color-primary);
    background: rgba(139, 92, 246, 0.05);
}

.avatar-upload-area.dragover {
    border-color: var(--color-primary);
    background: rgba(139, 92, 246, 0.1);
}

.avatar-preview {
    width: 120px;
    height: 120px;
    margin: 0 auto 1rem;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-preview-placeholder {
    width: 60%;
    height: 60%;
    opacity: 0.3;
}

.avatar-upload-text {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    margin-bottom: 0.5rem;
}

.avatar-upload-hint {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    opacity: 0.7;
}

input[type="file"] {
    display: none;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.btn-primary,
.btn-secondary {
    flex: 1;
    padding: 1rem 2rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: 1rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-primary:hover {
    background: #7c3aed;
    transform: scale(1.02);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.password-modal-content {
    padding: 1.5rem;
}

.password-info {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1.5rem;
    color: #3b82f6;
    font-size: 0.9rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.password-info svg {
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.manage-actions-modal {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.manage-actions-modal .btn-action {
    width: 100%;
    padding: 1rem;
    border-radius: var(--radius-md);
    font-weight: 700;
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-size: 1rem;
}

.btn-action.edit {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    border-color: rgba(59, 130, 246, 0.3);
}

.btn-action.edit:hover {
    background: rgba(59, 130, 246, 0.2);
}

.btn-action.password {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
    border-color: rgba(245, 158, 11, 0.3);
}

.btn-action.password:hover {
    background: rgba(245, 158, 11, 0.2);
}

.btn-action.delete {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
}

.btn-action.delete:hover {
    background: rgba(239, 68, 68, 0.2);
}

.btn-action.anilist {
    background: rgba(2, 169, 255, 0.1);
    color: #02a9ff;
    border-color: rgba(2, 169, 255, 0.3);
}

.btn-action.anilist:hover {
    background: rgba(2, 169, 255, 0.2);
}

.btn-action.cancel {
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-text-secondary);
}

.btn-action.cancel:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.anilist-status {
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
}

.anilist-connected {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.anilist-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, #02a9ff 0%, #0170d9 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    color: white;
}

.anilist-info h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.anilist-info p {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
}

.btn-disconnect {
    width: 100%;
    padding: 1rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
    border-radius: var(--radius-md);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-disconnect:hover {
    background: rgba(239, 68, 68, 0.2);
}

.btn-connect {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, #02a9ff 0%, #0170d9 100%);
    border: none;
    color: white;
    border-radius: var(--radius-md);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-connect:hover {
    transform: scale(1.02);
    box-shadow: 0 10px 30px rgba(2, 169, 255, 0.3);
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    animation: fadeInUp 0.8s ease;
}

.empty-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    opacity: 0.3;
}

.empty-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.empty-text {
    font-size: 1.1rem;
    color: var(--color-text-secondary);
    margin-bottom: 2rem;
}

#userToastContainer {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.wb-toast {
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    color: white;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.5s ease-out;
    pointer-events: all;
    min-width: 250px;
}

.wb-toast.show {
    opacity: 1;
    transform: translateX(0);
}

.wb-toast.success {
    background: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.4);
}

.wb-toast.error {
    background: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.wb-toast.info {
    background: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.4);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.skeleton {
    background: linear-gradient(90deg, #18181b 25%, #27272a 50%, #18181b 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

@media (max-width: 768px) {
    .page-wrapper {
        padding: 1rem;

        align-items: flex-start;
        padding-top: 2rem;
    }

    .header-section {
        margin-bottom: 2rem;
    }

    .page-title {
        font-size: 2.2rem;
        line-height: 1.1;
    }

    .users-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
        max-width: 100%;
    }

    .user-name {
        font-size: 1.1rem;
        font-weight: 800;
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    }

    .user-config-btn {
        width: 44px;
        height: 44px;
        top: 5px;
        right: 5px;
        background: rgba(0, 0, 0, 0.6);
        opacity: 1 !important;
    }

    .user-config-btn svg {
        width: 20px;
        height: 20px;
    }

    .btn-add-user {
        width: 100%;
        padding: 1.25rem;
        font-size: 1.1rem;
        margin-bottom: 3rem;
    }
}

@media (max-width: 380px) {
    .users-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .user-card {
        aspect-ratio: 16/9;
    }
}

@media (hover: none) {
    .user-info {
        transform: translateY(0);
        background: linear-gradient(
            to top,
            rgba(0, 0, 0, 0.95) 0%,
            rgba(0, 0, 0, 0.6) 50%,
            transparent 100%
        );
        padding: 1rem;
    }

    .user-card:hover {
        transform: none;
        border-color: rgba(255, 255, 255, 0.1);
    }

    .user-card:active {
        transform: scale(0.97);
        border-color: var(--color-primary);
    }
}

@media (max-width: 768px) {
    .modal {
        align-items: flex-end;
    }

    .modal-content {
        width: 100%;
        max-width: 100%;
        border-radius: 20px 20px 0 0;
        max-height: 85vh;
        padding: 1.5rem;
        overflow-y: auto;
    }

    .form-group input[type="text"],
    .form-group input[type="password"] {
        padding: 1.2rem;
        font-size: 16px;
    }

    .btn-primary,
    .btn-secondary {
        padding: 1.2rem;
    }
}
