/* ============================================
   Shared CSS - Common Components
   ============================================
   Background Gradient, Top Bar, Sidebar, Buttons
   Used across all pages (viewer, make, studio)
   ============================================ */


/* ============================================
   Background Gradient System
   ============================================ */

.bg-gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: var(--z-bg);
    pointer-events: none;
    background: #0a0a1e;
}


/* 전체 페이지 미세한 그라데이션 오버레이 */

.bg-gradient::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient( circle at 50% 40%, rgba(139, 92, 246, 0.03) 0%, rgba(34, 211, 238, 0.02) 30%, transparent 60%);
    pointer-events: none;
}


/* ============================================
   Top Bar Component (Fixed Positioning)
   ============================================ */

.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background: transparent;
    backdrop-filter: blur(5px);
    border-radius: 22px;
    box-shadow: var(--shadow-md);
    z-index: var(--z-top-bar);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 26px;
}

.top-bar__logo {
    display: flex;
    align-items: center;
    gap: 4px;
    /* Figma design spacing */
    text-decoration: none;
    color: inherit;
    margin-left: -19px;
    /* Move logo and text 19px to the left */
}

.top-bar__logo-image {
    width: 54px;
    /* Figma design size */
    height: 54px;
    /* Figma design size */
    object-fit: contain;
    /* Maintain aspect ratio, prevent distortion */
    border-radius: 8px;
    /* Rounded corners for modern look */
}

.top-bar__logo-text {
    font-family: 'Inria Sans', sans-serif;
    font-size: 20px;
    font-weight: 700;
    color: #cdd5de;
}

.top-bar__actions {
    display: flex;
    align-items: center;
    gap: 10px;
    /* Figma Design: 10px gap */
    margin-left: auto;
}

.top-bar__profile {
    width: 50px;
    /* Figma Design: 50px */
    height: 50px;
    /* Figma Design: 50px */
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--brand-primary);
    border-radius: var(--radius-full);
    font-size: 20px;
    /* Figma Design: 20px */
    font-weight: 500;
    /* Figma Design: Inter Medium */
    font-family: 'Inter', sans-serif;
    letter-spacing: 0.576px;
    /* Figma Design */
    cursor: pointer;
    box-shadow: 0px 0px 30px rgba(227, 235, 255, 0.22), 0px 6px 40px rgba(16, 24, 40, 0.08);
    /* Figma Design Shadow */
}

.top-bar__notification img {
    width: 24px !important;
    height: 24px !important;
}


/* Common icon container - unified 44px design */

.top-bar__icon-container {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    transition: background var(--duration-fast) var(--ease-default);
    padding: 0;
}

.top-bar__icon-container:hover {
    background: rgba(255, 255, 255, 0.08);
}


/* Language button (inherits icon-container) */

.top-bar__language {
    width: 44px;
    height: 44px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    transition: background var(--duration-fast) var(--ease-default);
}

.top-bar__language:hover {
    background: rgba(255, 255, 255, 0.08);
}


/* Social link (inherits icon-container) */

.top-bar__social-link {
    width: 44px;
    height: 44px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: background var(--duration-fast) var(--ease-default);
}

.top-bar__social-link:hover {
    background: rgba(255, 255, 255, 0.08);
}


/* Social Media Container (Figma Design) */

.top-bar__social-container {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 18px;
    height: 32px;
}

.top-bar__social-icon {
    width: 21px;
    height: 21px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: transform 0.2s ease;
}

.top-bar__social-icon:hover {
    transform: scale(1.15);
}

.top-bar__social-icon img {
    width: 100%;
    height: 100%;
    display: block;
}


/* ============================================
   Hamburger Menu Button (Mobile)
   ============================================ */

.hamburger {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    z-index: var(--z-hamburger);
    order: -1;
    margin-right: auto;
}

.hamburger span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: var(--transition);
}


/* Hamburger active state animation */

.hamburger.active span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}


/* ============================================
   Sidebar Component (Fixed Positioning)
   ============================================ */

.sidebar {
    position: fixed;
    left: 0;
    top: var(--topbar-height);
    width: var(--sidebar-width);
    height: auto;
    max-height: calc(100vh - var(--topbar-height));
    background: rgba(26, 26, 46, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 0 16px 16px 0;
    transition: width var(--duration-normal) var(--ease-in-out), transform var(--duration-normal) var(--ease-default);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: var(--z-sidebar);
    scrollbar-width: none;
}

.sidebar::-webkit-scrollbar {
    display: none;
}

.sidebar--collapsed {
    width: var(--sidebar-width);
}

.sidebar:hover {
    width: var(--sidebar-width-expanded);
}

.sidebar__content {
    display: flex;
    flex-direction: column;
    padding-bottom: var(--space-3);
}

.sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-1);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-1) var(--space-2) 16px;
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--duration-fast) var(--ease-default);
    position: relative;
}

.nav-item:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.nav-item--active {
    background: #4920ef !important;
    color: var(--text-primary);
}

.nav-item--active::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background: #6366f1;
    border-radius: 2px 0 0 2px;
}

.nav-item__icon {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.nav-item__icon img {
    width: 30px;
    height: 30px;
    object-fit: contain;
}


/* Footer icons (Support, Privacy, Terms) - 30% smaller */

.nav-item__icon img[src*="side_sub_"] {
    width: 21px;
    height: 21px;
}

.nav-item__label {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    white-space: nowrap;
    opacity: 0;
    transition: opacity var(--duration-normal);
}

.sidebar:hover .nav-item__label {
    opacity: 1;
}

.sidebar__divider {
    height: 0;
    border-top: 1px solid var(--border-default);
    margin: var(--space-3) 0;
}

.sidebar__upgrade {
    padding: 0 var(--space-2);
    margin-top: auto;
}

.btn-upgrade {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: #6366f1;
    color: white;
    border: none;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-in-out);
}

.btn-upgrade:hover {
    background: #5558e3;
}

.sidebar--collapsed .sidebar__upgrade {
    display: none;
}

.sidebar__profile {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-2);
    margin: var(--space-2) var(--space-2) var(--space-2) var(--space-2);
    cursor: pointer;
}

.sidebar__profile-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.sidebar__profile-info {
    flex: 1;
    min-width: 0;
}

.sidebar__profile-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar__profile-status {
    font-size: 12px;
    color: var(--text-secondary);
}

.sidebar--collapsed .sidebar__profile-info {
    display: none;
}

.sidebar__profile-caret {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 12px;
}

.sidebar--collapsed .sidebar__profile-caret {
    display: none;
}


/* ============================================
   Main Container & Content (Fixed Layout)
   ============================================ */

.main-container {
    display: flex;
    margin-top: var(--topbar-height);
    min-height: calc(100vh - var(--topbar-height));
    position: relative;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: var(--space-6);
    max-width: calc(100% - var(--sidebar-width));
    transition: margin-left var(--duration-normal) var(--ease-in-out);
    overflow-y: auto;
    overflow-x: hidden;
}


/* ============================================
   Overlay for Mobile Sidebar
   ============================================ */

.overlay {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--z-overlay);
    display: none;
    opacity: 0;
    transition: opacity var(--duration-normal) var(--ease-default);
}

.overlay.active {
    display: block;
    opacity: 1;
}


/* ============================================
   Common Buttons
   ============================================ */


/* Top bar buttons - matched to logo text height */

.top-bar .btn-primary {
    padding: 9px 20px;
    /* Figma Design - Updated padding */
    background: linear-gradient(90deg, #48A5E6 0%, #4459F5 53.846%, #B335F1 100%);
    /* Figma Design Gradient - Blue to Purple */
    color: white;
    border: none;
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    /* Figma Design */
    font-size: 20px;
    /* Figma Design */
    font-weight: 500;
    /* Figma Design: Inter Medium */
    letter-spacing: -1px;
    /* Figma Design */
    line-height: 1.08;
    /* Figma Design: 21.6px / 20px */
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: all var(--duration-fast) var(--ease-default);
}

.top-bar .btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}


/* Generic btn-primary for other uses */

.btn-primary {
    padding: 12px 24px;
    background: var(--brand-primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-default);
}

.btn-primary:hover {
    background: #5a3dd6;
}


/* ============================================
   Common Tags
   ============================================ */

.tag {
    padding: 3px 10px;
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    color: var(--text-tag);
}

.tag-pill {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--border-tag);
    border-radius: var(--radius-full);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    font-weight: var(--font-medium);
}


/* ============================================
   Common Avatars
   ============================================ */

.avatar {
    position: relative;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar--sm {
    width: 46px;
    height: 46px;
}

.avatar-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: var(--font-semibold);
    color: white;
}


/* ============================================
   Verified Badge
   ============================================ */

.verified-icon {
    width: 16px;
    height: 16px;
}


/* ============================================
   User Menu & Dropdown
   ============================================ */

.user-menu {
    position: relative;
    display: inline-block;
}

.user-button {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    transition: all var(--duration-fast) ease;
}

.user-button:hover {
    background: transparent;
}

.user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    min-width: 200px;
    z-index: 1000;
    overflow: hidden;
}

.user-dropdown.active {
    display: block;
    animation: slideDown 0.2s ease;
}

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

.dropdown-item {
    display: block;
    padding: var(--space-3) var(--space-4);
    color: var(--text-primary);
    text-decoration: none;
    font-size: var(--text-sm);
    cursor: pointer;
    transition: background var(--duration-fast) ease;
}

.dropdown-item:hover {
    background: var(--bg-hover);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-default);
    margin: var(--space-1) 0;
}


/* ============================================
   Language Selector & Dropdown
   ============================================ */

.language-selector-container {
    position: relative;
    display: inline-block;
}

.language-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    min-width: 180px;
    z-index: 1000;
    overflow: hidden;
}

.language-dropdown.active {
    display: block;
    animation: slideDown 0.2s ease;
}

.language-option {
    display: flex;
    align-items: center;
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: transparent;
    border: none;
    color: var(--text-primary);
    text-align: left;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    cursor: pointer;
    transition: background var(--duration-fast) ease;
}

.language-option:hover {
    background: var(--bg-hover);
}

.language-option.active {
    background: var(--bg-hover);
    color: var(--brand-primary);
}


/* ============================================
   Mobile Responsive Design (768px Breakpoint)
   ============================================ */

@media (max-width: 768px) {
    /* Show hamburger menu */
    .hamburger {
        display: flex;
    }
    /* Hide sidebar by default on mobile */
    .sidebar {
        transform: translateX(-100%);
        z-index: var(--z-sidebar);
        transition: transform var(--duration-normal) var(--ease-default);
    }
    /* Show sidebar when active */
    .sidebar.active {
        transform: translateX(0);
    }
    /* Disable hover expansion on mobile */
    .sidebar:hover {
        width: var(--sidebar-width);
    }
    .sidebar.active:hover {
        width: var(--sidebar-width);
    }
    /* Main content takes full width */
    .main-content {
        margin-left: 0;
        max-width: 100%;
    }
    /* Adjust topbar actions */
    .top-bar__actions {
        gap: var(--space-2);
    }
    .top-bar .btn-primary {
        padding: 8px 20px;
        /* Updated to match Figma design */
        font-size: 16px;
        height: 36px;
    }
    /* Make sidebar wider on mobile */
    .sidebar.active {
        width: 80%;
        max-width: 300px;
    }
}


/* ============================================
   Smaller Mobile (480px Breakpoint)
   ============================================ */

@media (max-width: 480px) {
    /* Even smaller topbar padding */
    .top-bar {
        padding: 0 var(--space-3);
    }
    /* Sidebar takes more width on very small screens */
    .sidebar.active {
        width: 85%;
        max-width: 280px;
    }
    /* Smaller text for topbar logo */
    .top-bar__logo-text {
        font-size: 20px;
    }
    /* Adjust main content padding */
    .main-content {
        padding: var(--space-4);
    }
}