/* ================================================================
   Roblox Avatar 3D Downloader — Premium Dark Mode Stylesheet
   ================================================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Background */
    --bg-primary: #07070f;
    --bg-secondary: #0d0d1a;
    --bg-card: rgba(15, 15, 35, 0.65);
    --bg-card-hover: rgba(20, 20, 50, 0.75);
    --bg-input: rgba(20, 20, 50, 0.5);

    /* Accents */
    --accent-cyan: #3b82f6;
    --accent-purple: #8b5cf6;
    --accent-pink: #f43f5e;
    --accent-green: #10b981;
    --gradient-primary: linear-gradient(135deg, #3b82f6, #3b82f6);
    --gradient-secondary: linear-gradient(135deg, #4f46e5, #4f46e5);
    --gradient-glow: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(59, 130, 246, 0.1));

    /* Text */
    --text-primary: #f0f0f8;
    --text-secondary: #9ca3b8;
    --text-muted: #5a5f78;

    /* Glass */
    --glass-border: rgba(255, 255, 255, 0.06);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);

    /* Misc */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);

    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-display: 'Outfit', 'Inter', sans-serif;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Background --- */
.bg-particles {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
    background: var(--bg-primary);
}

/* --- Header --- */
.header {
    position: relative;
    z-index: 10;
    padding: 24px 32px;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(7, 7, 15, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    overflow: hidden;
}

.logo-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.logo-text {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.logo-highlight {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 400;
    letter-spacing: 0.02em;
}

/* --- Main Content --- */
.main-content {
    position: relative;
    z-index: 5;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* --- Search Section --- */
.search-section {
    text-align: center;
    padding: 80px 0 60px;
    animation: fadeInUp 0.8s ease-out;
}

.search-title {
    font-family: var(--font-display);
    font-size: clamp(2rem, 5vw, 3.2rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.15;
    margin-bottom: 16px;
    background: linear-gradient(135deg, #f0f0f8 0%, #9ca3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.search-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 48px;
    font-weight: 400;
    max-width: 520px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.6;
}

.search-bar-wrapper {
    display: flex;
    justify-content: center;
}

.search-bar {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--glass-border);
    border-radius: 60px;
    padding: 6px 6px 6px 24px;
    width: 100%;
    max-width: 560px;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    position: relative;
}

.search-bar::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 60px;
    padding: 1px;
    background: linear-gradient(135deg, rgba(6, 182, 212, 0), rgba(168, 85, 247, 0));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    transition: var(--transition-smooth);
    pointer-events: none;
}

.search-bar:focus-within {
    border-color: transparent;
    box-shadow: 0 4px 32px rgba(6, 182, 212, 0.15), 0 0 0 1px rgba(6, 182, 212, 0.2);
    background: rgba(20, 20, 55, 0.7);
}

.search-bar:focus-within::before {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.5), rgba(168, 85, 247, 0.5));
}

.search-icon {
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    flex-shrink: 0;
    margin-right: 12px;
    transition: var(--transition-fast);
}

.search-bar:focus-within .search-icon {
    color: var(--accent-cyan);
}

#usernameInput {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: var(--font-primary);
    font-weight: 500;
    letter-spacing: 0.01em;
    min-width: 0;
}

#usernameInput::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.search-btn {
    flex-shrink: 0;
    padding: 12px 28px;
    border: none;
    border-radius: 50px;
    background: var(--gradient-primary);
    color: #fff;
    font-family: var(--font-primary);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.search-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
    opacity: 0;
    transition: var(--transition-fast);
}

.search-btn:hover::before {
    opacity: 1;
}

.search-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(6, 182, 212, 0.3);
}

.search-btn:active {
    transform: translateY(0);
}

.search-btn.loading .btn-text { visibility: hidden; }
.search-btn.loading .btn-loader { display: block; }

.btn-loader {
    display: none;
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* --- hCaptcha Widget --- */
.captcha-wrapper {
    display: flex;
    justify-content: center;
    margin-top: 24px;
    animation: fadeInUp 0.5s ease-out 0.3s both;
}

.captcha-wrapper .h-captcha {
    transform: scale(0.95);
    transform-origin: center;
}

/* --- Search Error --- */
.search-error {
    margin-top: 16px;
    color: #f87171;
    font-size: 0.9rem;
    font-weight: 500;
    min-height: 24px;
    transition: var(--transition-fast);
}

/* --- Results Section --- */
.results-section {
    padding-bottom: 80px;
    animation: fadeInUp 0.6s ease-out;
}

.results-section.hidden {
    display: none;
}

/* --- Glass Card --- */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--glass-shadow);
    transition: var(--transition-smooth);
}

.glass-card:hover {
    background: var(--bg-card-hover);
    border-color: rgba(255, 255, 255, 0.08);
}

/* --- User Card --- */
.user-card {
    padding: 32px 36px;
    margin-bottom: 28px;
    animation: fadeInUp 0.5s ease-out 0.1s both;
}

.user-card-inner {
    display: flex;
    align-items: center;
    gap: 28px;
}

.user-avatar-wrapper {
    position: relative;
    flex-shrink: 0;
}

.user-avatar {
    width: 90px;
    height: 90px;
    border-radius: var(--radius-md);
    object-fit: cover;
    display: block;
    position: relative;
    z-index: 1;
}

.avatar-ring {
    position: absolute;
    inset: -3px;
    border-radius: calc(var(--radius-md) + 3px);
    background: var(--gradient-primary);
    z-index: 0;
    opacity: 0.7;
    animation: pulseRing 3s ease-in-out infinite;
}

@keyframes pulseRing {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.02); }
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.user-display-name {
    font-family: var(--font-display);
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.user-username {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 400;
}

.user-id-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 50px;
    background: var(--gradient-glow);
    border: 1px solid rgba(6, 182, 212, 0.15);
    font-size: 0.78rem;
    color: var(--accent-cyan);
    font-weight: 600;
    letter-spacing: 0.03em;
    width: fit-content;
    font-variant-numeric: tabular-nums;
}

/* --- Content Grid --- */
.content-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 24px;
    animation: fadeInUp 0.5s ease-out 0.2s both;
}

/* --- Card Header --- */
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--glass-border);
}

.card-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.card-icon {
    width: 20px;
    height: 20px;
    color: var(--accent-cyan);
}

/* --- Viewer Controls --- */
.viewer-controls {
    display: flex;
    gap: 6px;
}

.control-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.control-btn svg {
    width: 16px;
    height: 16px;
}

.control-btn:hover {
    background: rgba(6, 182, 212, 0.1);
    border-color: rgba(6, 182, 212, 0.3);
    color: var(--accent-cyan);
}

.control-btn.active {
    background: rgba(6, 182, 212, 0.15);
    border-color: rgba(6, 182, 212, 0.4);
    color: var(--accent-cyan);
}

/* --- 3D Viewer --- */
.viewer-container {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    background: radial-gradient(ellipse at center, #12122a 0%, #08081a 100%);
}

#viewerCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.viewer-hint {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 6px 16px;
    border-radius: 50px;
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.viewer-container:hover .viewer-hint {
    opacity: 1;
}

/* --- Viewer Loading --- */
.viewer-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    z-index: 5;
    background: rgba(8, 8, 26, 0.9);
}

.viewer-loading.hidden {
    display: none;
}

/* Spinning cube loader */
.cube-loader {
    width: 48px;
    height: 48px;
    position: relative;
    transform-style: preserve-3d;
    animation: cubeRotate 2.5s ease-in-out infinite;
}

.cube-face {
    position: absolute;
    width: 48px;
    height: 48px;
    border: 2px solid rgba(6, 182, 212, 0.4);
    background: rgba(6, 182, 212, 0.06);
}

.cube-face.front  { transform: translateZ(24px); }
.cube-face.back   { transform: rotateY(180deg) translateZ(24px); }
.cube-face.right  { transform: rotateY(90deg) translateZ(24px); }
.cube-face.left   { transform: rotateY(-90deg) translateZ(24px); }
.cube-face.top    { transform: rotateX(90deg) translateZ(24px); }
.cube-face.bottom { transform: rotateX(-90deg) translateZ(24px); }

@keyframes cubeRotate {
    0%   { transform: rotateX(-30deg) rotateY(0deg); }
    50%  { transform: rotateX(-30deg) rotateY(180deg); }
    100% { transform: rotateX(-30deg) rotateY(360deg); }
}

.loading-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* --- Viewer Error --- */
.viewer-error {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 5;
    background: rgba(8, 8, 26, 0.9);
}

.viewer-error.hidden {
    display: none;
}

.error-icon-large {
    width: 48px;
    height: 48px;
    color: #f87171;
}

.error-text {
    font-size: 0.9rem;
    color: #f87171;
    font-weight: 500;
    text-align: center;
    max-width: 260px;
    line-height: 1.5;
}

/* --- Download Card --- */
.download-card .download-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* --- Download All Button --- */
.download-all-btn {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    border: 1px solid rgba(6, 182, 212, 0.2);
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.08), rgba(168, 85, 247, 0.08));
    cursor: pointer;
    transition: var(--transition-smooth);
    width: 100%;
    text-align: left;
    color: var(--text-primary);
    font-family: var(--font-primary);
    position: relative;
    overflow: hidden;
}

.download-all-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--gradient-primary);
    opacity: 0;
    transition: var(--transition-smooth);
}

.download-all-btn:hover::before {
    opacity: 0.12;
}

.download-all-btn:hover {
    border-color: rgba(6, 182, 212, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(6, 182, 212, 0.15);
}

.download-all-btn:active {
    transform: translateY(0);
}

.download-all-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.download-all-icon svg {
    width: 20px;
    height: 20px;
    color: #fff;
}

.download-all-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    position: relative;
    z-index: 1;
}

.download-all-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.download-all-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.download-all-badge {
    padding: 4px 10px;
    border-radius: 50px;
    background: rgba(6, 182, 212, 0.12);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--accent-cyan);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    position: relative;
    z-index: 1;
}

/* --- File List --- */
.file-list-header {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.02);
    transition: var(--transition-fast);
    margin-bottom: 8px;
}

.file-item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.1);
}

.file-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.file-icon.obj {
    background: rgba(34, 197, 94, 0.12);
    color: var(--accent-green);
}

.file-icon.mtl {
    background: rgba(168, 85, 247, 0.12);
    color: var(--accent-purple);
}

.file-icon.tex {
    background: rgba(236, 72, 153, 0.12);
    color: var(--accent-pink);
}

.file-name {
    flex: 1;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-download-btn {
    width: 30px;
    height: 30px;
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
    flex-shrink: 0;
}

.file-download-btn svg {
    width: 14px;
    height: 14px;
}

.file-download-btn:hover {
    background: rgba(6, 182, 212, 0.1);
    border-color: rgba(6, 182, 212, 0.3);
    color: var(--accent-cyan);
}

/* --- Footer --- */
.footer {
    position: relative;
    z-index: 5;
    text-align: center;
    padding: 32px 24px;
    border-top: 1px solid var(--glass-border);
    color: var(--text-muted);
    font-size: 0.8rem;
}

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

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

/* --- Responsive --- */
@media (max-width: 900px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .header-inner {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }

    .search-section {
        padding: 48px 0 40px;
    }

    .search-bar {
        flex-direction: column;
        border-radius: var(--radius-md);
        padding: 12px;
        gap: 10px;
    }

    .search-bar::before {
        border-radius: var(--radius-md);
    }

    .search-icon {
        display: none;
    }

    #usernameInput {
        width: 100%;
        text-align: center;
    }

    .search-btn {
        width: 100%;
        justify-content: center;
    }

    .user-card-inner {
        flex-direction: column;
        text-align: center;
    }

    .user-id-badge {
        margin: 0 auto;
    }

    .user-card {
        padding: 24px 20px;
    }
}
