:root {
    --bg-color-from: #0f172a;
    --bg-color-to: #1e1b4b;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --error-color: #ef4444;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

body {
    background: linear-gradient(135deg, var(--bg-color-from), var(--bg-color-to));
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

.background-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    background: radial-gradient(circle at 15% 50%, rgba(99, 102, 241, 0.15), transparent 25%),
                radial-gradient(circle at 85% 30%, rgba(236, 72, 153, 0.15), transparent 25%);
    filter: blur(60px);
    animation: pulse 15s ease-in-out infinite alternate;
}

@keyframes pulse {
    0% { transform: scale(1); }
    100% { transform: scale(1.1); }
}

/* Glassmorphism Classes */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.glass-header {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--glass-border);
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand-title {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(to right, #a855f7, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-align: center;
    margin-bottom: 8px;
}

.brand-title.small {
    font-size: 1.5rem;
    margin-bottom: 0;
    text-align: left;
}

.subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 30px;
    font-size: 0.95rem;
}

/* Forms and Buttons */
form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

input {
    width: 100%;
    padding: 14px 16px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.btn {
    padding: 14px 24px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    outline: none;
    width: 100%;
}

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

.btn.primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.4);
}

.btn.secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

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

.btn.small {
    width: auto;
    padding: 8px 16px;
    font-size: 0.875rem;
    border-radius: 8px;
}

.btn.error {
    background: transparent;
    color: var(--error-color);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn.error:hover {
    background: rgba(239, 68, 68, 0.1);
}

.error-text {
    color: var(--error-color);
    font-size: 0.875rem;
    text-align: center;
    min-height: 20px;
}

.hidden {
    display: none !important;
}

/* App Gallery Container */
#app-container {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* Category Tab Bar */
.tab-bar {
    display: flex;
    gap: 6px;
    padding: 12px 40px;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--glass-border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    position: sticky;
    top: 0;
    z-index: 9;
    flex-shrink: 0;
}

.tab-bar::-webkit-scrollbar { display: none; }

.tab-btn {
    flex-shrink: 0;
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    padding: 8px 18px;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-family: 'Inter', sans-serif;
}

.tab-btn:hover {
    color: var(--text-primary);
    border-color: rgba(99, 102, 241, 0.4);
    background: rgba(99, 102, 241, 0.1);
}

.tab-btn.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(168, 85, 247, 0.25));
    border-color: rgba(99, 102, 241, 0.6);
    color: var(--text-primary);
    box-shadow: 0 0 14px rgba(99, 102, 241, 0.2);
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    font-size: 1rem;
}

@media (max-width: 600px) {
    .tab-bar {
        padding: 10px 16px;
    }
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    padding: 40px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* App Card */
.app-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 24px;
    cursor: pointer;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
    overflow: hidden;
}

.app-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.05), transparent);
    transform: translateX(-100%);
    transition: 0.5s;
}

.app-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
    border-color: rgba(99, 102, 241, 0.5);
    background: rgba(255, 255, 255, 0.08);
}

.app-card:hover::before {
    transform: translateX(100%);
}

.app-icon {
    font-size: 3rem;
    margin-bottom: 8px;
    display: inline-block;
}

.app-info h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.app-info p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.app-meta {
    margin-top: auto;
    display: inline-block;
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    align-self: flex-start;
}

.user-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

#user-display {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

@media (max-width: 600px) {
    .glass-header {
        padding: 16px 20px;
        flex-direction: column;
        gap: 12px;
    }
    
    .gallery-grid {
        padding: 20px;
        grid-template-columns: 1fr;
    }
}

/* In-App Viewer */
.viewer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-color-from);
    z-index: 100;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.viewer-header {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--glass-border);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    z-index: 101;
}

.viewer-title {
    color: var(--text-primary);
    font-size: 1.25rem;
    margin: 0;
}

.viewer-content {
    flex: 1;
    width: 100%;
    height: 100%;
    background: var(--bg-color-from);
}

#app-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    background: var(--bg-color-from);
    color-scheme: dark;
}
