/* ============================================
   TOOLS HUB V2 - COMPLETE STYLES
   ============================================ */

:root {
    --primary: #8b5cf6;
    --primary-dark: #7c3aed;
    --primary-light: #a78bfa;
    --accent: #06b6d4;
    --accent-video: #f59e0b;
    --accent-ugc: #10b981;
    
    --bg-dark: #050510;
    --bg-sidebar: #0a0a15;
    --bg-main: #0d0d18;
    --bg-card: #12121f;
    --bg-input: #1a1a2e;
    --bg-message-user: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    --bg-message-bot: #1e1e2d;
    
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    
    --border-color: #27272a;
    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;
    
    --sidebar-left-width: 240px;
    --sidebar-left-collapsed: 70px;
    --sidebar-right-width: 300px;
    --header-height: 60px;
    --vh: 1vh;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; height: -webkit-fill-available; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
}

/* ============================================
   LOGIN SCREEN
   ============================================ */

.login-screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(180deg, var(--bg-dark) 0%, #1a1025 100%);
    z-index: 1000;
}

.login-container { text-align: center; max-width: 380px; width: 100%; }
.login-logo { margin-bottom: 40px; }

.login-logo .logo-icon {
    width: 90px; height: 90px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    border-radius: 28px;
    display: flex; align-items: center; justify-content: center;
    font-size: 3rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.login-logo h1 {
    font-size: 2.2rem; font-weight: 700;
    background: linear-gradient(to right, var(--primary-light), var(--accent));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.login-logo p { color: var(--text-secondary); margin-top: 5px; }
.login-features { margin-bottom: 40px; }

.feature-item {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 20px;
    background: var(--bg-card);
    border-radius: 12px; margin-bottom: 10px;
    font-size: 0.95rem; color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.feature-icon { font-size: 1.4rem; }

.btn-google {
    width: 100%;
    display: flex; align-items: center; justify-content: center; gap: 12px;
    padding: 16px 24px;
    background: white; color: #333;
    border: none; border-radius: 50px;
    font-size: 1rem; font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-google:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(255,255,255,0.15);
}

/* ============================================
   MAIN APP LAYOUT
   ============================================ */

.main-app {
    display: grid;
    grid-template-columns: var(--sidebar-left-width) 1fr var(--sidebar-right-width);
    height: 100vh; height: 100dvh;
    overflow: hidden;
}

.main-app.left-collapsed { grid-template-columns: var(--sidebar-left-collapsed) 1fr var(--sidebar-right-width); }
.main-app.right-collapsed { grid-template-columns: var(--sidebar-left-width) 1fr 0; }
.main-app.left-collapsed.right-collapsed { grid-template-columns: var(--sidebar-left-collapsed) 1fr 0; }

/* ============================================
   LEFT SIDEBAR
   ============================================ */

.sidebar-left {
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex; flex-direction: column;
    overflow: hidden;
    transition: width 0.3s ease;
}

.sidebar-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 15px;
    border-bottom: 1px solid var(--border-color);
    min-height: 70px;
}

.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; overflow: hidden; }
.logo-icon { font-size: 1.8rem; flex-shrink: 0; }

.logo-text {
    font-size: 1.2rem; font-weight: 700;
    background: linear-gradient(to right, var(--primary-light), var(--accent));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    white-space: nowrap;
}

.btn-collapse {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    background: transparent; border: none;
    color: var(--text-muted); border-radius: 8px;
    cursor: pointer; flex-shrink: 0;
}

.btn-collapse:hover { background: var(--bg-card); color: var(--text-primary); }
.btn-collapse svg { width: 16px; height: 16px; }

/* Collapsed left */
.main-app.left-collapsed .sidebar-left .logo-text,
.main-app.left-collapsed .sidebar-left .user-info,
.main-app.left-collapsed .sidebar-left .nav-text,
.main-app.left-collapsed .sidebar-left .nav-badge,
.main-app.left-collapsed .sidebar-left .nav-section-label,
.main-app.left-collapsed .sidebar-left .btn-label { display: none; }

.main-app.left-collapsed .sidebar-left .sidebar-header { justify-content: center; padding: 20px 10px; }
.main-app.left-collapsed .sidebar-left .sidebar-user { justify-content: center; padding: 15px 10px; }
.main-app.left-collapsed .sidebar-left .nav-item { justify-content: center; padding: 14px 10px; }
.main-app.left-collapsed .sidebar-left .sidebar-footer { padding: 15px 10px; }
.main-app.left-collapsed .sidebar-left .upgrade-btn,
.main-app.left-collapsed .sidebar-left .logout-btn { justify-content: center; padding: 12px 10px; }
.main-app.left-collapsed .sidebar-left .btn-collapse svg { transform: rotate(180deg); }

/* User */
.sidebar-user {
    display: flex; align-items: center; gap: 12px;
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-user img { width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0; }

.user-info { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

#sidebar-name {
    font-weight: 500; font-size: 0.9rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.plan-badge {
    font-size: 0.65rem; color: var(--primary-light);
    background: rgba(139, 92, 246, 0.15);
    padding: 2px 8px; border-radius: 10px;
    width: fit-content; margin-top: 3px;
}

/* Nav */
.sidebar-nav { flex: 1; overflow-y: auto; padding: 15px 10px; }
.nav-section { margin-bottom: 20px; }

.nav-section-label {
    font-size: 0.6rem; font-weight: 600;
    color: var(--text-muted); letter-spacing: 0.1em;
    padding: 0 10px; margin-bottom: 8px;
    text-transform: uppercase;
}

.nav-item {
    width: 100%;
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px;
    background: transparent; border: none;
    color: var(--text-secondary); font-size: 0.85rem;
    border-radius: 10px; cursor: pointer;
    transition: all 0.2s; margin-bottom: 4px;
    text-align: left;
}

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

.nav-item.active {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(6, 182, 212, 0.1));
    color: var(--text-primary);
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.nav-item.active[data-tool="ugc"] {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(6, 182, 212, 0.1));
    border-color: rgba(16, 185, 129, 0.3);
}

.nav-item.disabled { opacity: 0.4; cursor: not-allowed; }

.nav-icon { font-size: 1.2rem; flex-shrink: 0; }
.nav-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav-badge {
    font-size: 0.65rem; padding: 2px 7px; border-radius: 10px;
    background: var(--primary); color: white; flex-shrink: 0;
}

.nav-badge.soon { background: var(--bg-input); color: var(--text-muted); }

/* Footer */
.sidebar-footer { padding: 15px; border-top: 1px solid var(--border-color); }

.upgrade-btn {
    width: 100%;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 11px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border: none; border-radius: 10px;
    color: white; font-size: 0.85rem; font-weight: 500;
    text-decoration: none; margin-bottom: 10px;
    transition: all 0.2s;
}

.upgrade-btn:hover { opacity: 0.9; }

.logout-btn {
    width: 100%;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-muted); font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--error);
    color: var(--error);
}

.logout-btn svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ============================================
   MAIN CONTENT
   ============================================ */

.main-content {
    background: var(--bg-main);
    display: flex; flex-direction: column;
    overflow: hidden; min-width: 0;
}

.tool-panel {
    display: none;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.tool-panel.active { display: flex; }

.panel-inner {
    display: flex; flex-direction: column;
    height: 100%;
    max-width: 700px; width: 100%;
    margin: 0 auto;
    overflow: hidden;
}

/* Chat Area */
.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
}

/* Welcome */
.welcome-box {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    min-height: 50vh;
    text-align: center; padding: 20px;
}

.welcome-box.hidden { display: none; }

.welcome-icon { font-size: 4rem; margin-bottom: 15px; }
.welcome-box h2 { font-size: 1.4rem; margin-bottom: 5px; }
.welcome-box p { color: var(--text-secondary); margin-bottom: 25px; font-size: 0.9rem; }

.chips-container {
    display: flex; flex-wrap: wrap; justify-content: center;
    gap: 8px; max-width: 420px; margin-bottom: 15px;
}

.chip {
    padding: 9px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    color: var(--text-secondary); font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.chip:hover {
    background: var(--bg-input);
    border-color: var(--primary);
    color: var(--text-primary);
}

.info-notice {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: 10px;
    color: var(--warning); font-size: 0.75rem;
}

/* Messages */
.messages-list { display: flex; flex-direction: column; gap: 14px; }

.message {
    display: flex; gap: 10px;
    max-width: 85%;
    animation: msgIn 0.3s ease-out;
}

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

.message.user { align-self: flex-end; flex-direction: row-reverse; }
.message.bot { align-self: flex-start; }

.msg-avatar {
    width: 32px; height: 32px;
    border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.85rem;
}

.message.user .msg-avatar { background: var(--bg-card); }
.message.bot .msg-avatar { background: linear-gradient(135deg, var(--primary), var(--accent)); }
.message.bot .msg-avatar.video { background: linear-gradient(135deg, var(--primary), var(--accent-video)); }
.message.bot .msg-avatar.ugc { background: linear-gradient(135deg, var(--accent-ugc), var(--accent)); }

.msg-content { display: flex; flex-direction: column; gap: 5px; min-width: 0; }

.msg-bubble {
    padding: 11px 15px;
    border-radius: 16px;
    font-size: 0.9rem; line-height: 1.5;
    word-break: break-word;
}

.message.user .msg-bubble {
    background: var(--bg-message-user);
    border-bottom-right-radius: 4px;
}

.message.bot .msg-bubble {
    background: var(--bg-message-bot);
    border-bottom-left-radius: 4px;
}

.msg-time { font-size: 0.65rem; color: var(--text-muted); padding: 0 3px; }
.message.user .msg-time { text-align: right; }

/* Media */
.msg-media {
    position: relative;
    max-width: 260px;
    border-radius: 12px; overflow: hidden;
    cursor: pointer; background: #000;
}

.msg-media img, .msg-media video {
    width: 100%; display: block; border-radius: 12px;
}

.media-actions {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 35px 10px 10px;
    background: linear-gradient(transparent, rgba(0,0,0,0.75));
    display: flex; gap: 6px;
    opacity: 0;
    transition: opacity 0.2s;
}

.msg-media:hover .media-actions { opacity: 1; }
@media (hover: none) { .media-actions { opacity: 1; padding-top: 25px; } }

.media-btn {
    padding: 6px 10px;
    background: rgba(255,255,255,0.2);
    border: none; border-radius: 6px;
    color: white; font-size: 0.7rem;
    cursor: pointer;
    backdrop-filter: blur(8px);
    text-decoration: none;
}

.media-btn:hover { background: rgba(255,255,255,0.3); }

.source-thumb {
    max-width: 100px; border-radius: 6px;
    margin-bottom: 6px;
    border: 2px solid var(--primary);
}

.source-thumb.video { border-color: var(--accent-video); }
.source-thumb.ugc { border-color: var(--accent-ugc); }

.mode-tag {
    display: inline-block;
    padding: 2px 7px; border-radius: 8px;
    font-size: 0.65rem; font-weight: 500;
    margin-bottom: 5px;
    background: rgba(139, 92, 246, 0.2);
    color: var(--primary-light);
}

.mode-tag.video { background: rgba(245, 158, 11, 0.2); color: var(--accent-video); }
.mode-tag.ugc { background: rgba(16, 185, 129, 0.2); color: var(--accent-ugc); }

/* Loading */
.msg-loading {
    display: flex; flex-direction: column; gap: 10px;
    padding: 14px;
    background: var(--bg-message-bot);
    border-radius: 16px; border-bottom-left-radius: 4px;
    min-width: 200px;
}

.loading-top { display: flex; align-items: center; gap: 10px; }
.dots { display: flex; gap: 4px; }

.dot {
    width: 7px; height: 7px;
    background: var(--primary);
    border-radius: 50%;
    animation: bounce 1.4s infinite;
}

.dot.video { background: var(--accent-video); }
.dot.ugc { background: var(--accent-ugc); }
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-7px); opacity: 1; }
}

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

/* Progress */
.progress-wrap { margin-top: 6px; }

.progress-track {
    height: 5px;
    background: var(--bg-input);
    border-radius: 3px; overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 3px;
    transition: width 0.3s;
}

.progress-bar.video { background: linear-gradient(90deg, var(--primary), var(--accent-video)); }
.progress-bar.ugc { background: linear-gradient(90deg, var(--accent-ugc), var(--accent)); }

.progress-meta {
    display: flex; justify-content: space-between;
    margin-top: 5px; font-size: 0.7rem; color: var(--text-muted);
}

.progress-pct { color: var(--primary-light); font-weight: 500; }
.progress-pct.video { color: var(--accent-video); }
.progress-pct.ugc { color: var(--accent-ugc); }

/* Error */
.msg-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.retry-btn {
    padding: 7px 14px;
    background: var(--error);
    border: none; border-radius: 6px;
    color: white; font-size: 0.8rem;
    cursor: pointer; margin-top: 8px;
}

.refund-note { font-size: 0.7rem; color: var(--success); margin-top: 6px; }

/* ============================================
   INPUT SECTION (Image/Video)
   ============================================ */

.input-section {
    padding: 12px 20px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.preview-bar { display: none; margin-bottom: 10px; }
.preview-bar.active { display: block; }

.preview-inner {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px;
    background: var(--bg-card);
    border-radius: 10px;
    border: 1px solid var(--primary);
}

.preview-inner.video { border-color: var(--accent-video); }
.preview-inner.ugc { border-color: var(--accent-ugc); }

.preview-inner img {
    width: 45px; height: 45px;
    object-fit: cover; border-radius: 6px; flex-shrink: 0;
}

.preview-info { flex: 1; min-width: 0; font-size: 0.8rem; }
.preview-info .label { color: var(--primary-light); font-weight: 500; }
.preview-inner.video .preview-info .label { color: var(--accent-video); }
.preview-inner.ugc .preview-info .label { color: var(--accent-ugc); }
.preview-info .size { color: var(--text-muted); font-size: 0.7rem; }

.btn-remove-preview {
    width: 26px; height: 26px;
    display: flex; align-items: center; justify-content: center;
    background: transparent; border: none;
    color: var(--text-muted); border-radius: 50%;
    cursor: pointer; flex-shrink: 0;
}

.btn-remove-preview:hover { background: rgba(239, 68, 68, 0.2); color: var(--error); }
.btn-remove-preview svg { width: 16px; height: 16px; }

.ratio-selector {
    display: flex; justify-content: center;
    gap: 6px; margin-bottom: 10px;
}

.ratio-btn {
    display: flex; flex-direction: column; align-items: center;
    gap: 2px; padding: 6px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-muted); cursor: pointer;
    transition: all 0.2s; font-size: 0.6rem;
}

.ratio-btn svg { width: 20px; height: 20px; }
.ratio-btn:hover { border-color: var(--text-secondary); }

.ratio-btn.active { background: var(--primary); border-color: var(--primary); color: white; }
.ratio-btn.active.video { background: linear-gradient(135deg, var(--primary), var(--accent-video)); border-color: transparent; }

.input-row {
    display: flex; align-items: flex-end; gap: 8px;
    padding: 6px 8px;
    background: var(--bg-card);
    border-radius: 22px;
    border: 1px solid var(--border-color);
    transition: border-color 0.2s;
}

.input-row:focus-within { border-color: var(--primary); }
.input-row.video:focus-within { border-color: var(--accent-video); }

.btn-attach {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    background: transparent; border: none;
    color: var(--text-secondary); border-radius: 50%;
    cursor: pointer; flex-shrink: 0;
}

.btn-attach:hover { background: var(--bg-input); color: var(--primary-light); }
.btn-attach.video:hover { color: var(--accent-video); }
.btn-attach svg { width: 20px; height: 20px; }

.prompt-input {
    flex: 1;
    background: transparent; border: none;
    color: var(--text-primary);
    font-size: 15px; line-height: 1.4;
    resize: none; max-height: 90px;
    padding: 7px 0; min-width: 0;
    font-family: inherit;
}

.prompt-input::placeholder { color: var(--text-muted); }
.prompt-input:focus { outline: none; }

.btn-send {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    background: var(--primary);
    border: none; border-radius: 50%;
    color: white; cursor: pointer; flex-shrink: 0;
    transition: all 0.2s;
}

.btn-send.video { background: linear-gradient(135deg, var(--primary), var(--accent-video)); }
.btn-send.ugc { background: linear-gradient(135deg, var(--accent-ugc), var(--accent)); }

.btn-send:disabled { background: var(--bg-input); color: var(--text-muted); cursor: not-allowed; }
.btn-send:not(:disabled):hover { transform: scale(1.05); }
.btn-send svg { width: 16px; height: 16px; margin-left: 2px; }

/* ============================================
   UGC FORM PANEL
   ============================================ */

.ugc-form-panel {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
}

.ugc-form { max-width: 600px; margin: 0 auto; }

.ugc-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
}

.ugc-section h3 {
    font-size: 1rem;
    margin-bottom: 15px;
    color: var(--text-primary);
}

/* Upload boxes */
.ugc-upload-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.ugc-upload-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.ugc-upload-box {
    position: relative;
    background: var(--bg-input);
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 30px 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.ugc-upload-box:hover {
    border-color: var(--accent-ugc);
    background: rgba(16, 185, 129, 0.05);
}

.ugc-upload-box.has-preview {
    padding: 10px;
}

.ugc-upload-icon { font-size: 2rem; margin-bottom: 8px; }
.ugc-upload-text { font-size: 0.8rem; color: var(--text-muted); }

.ugc-upload-preview {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
    display: none;
}

.ugc-upload-box.has-preview .ugc-upload-placeholder { display: none; }
.ugc-upload-box.has-preview .ugc-upload-preview { display: block; }

/* Form fields */
.ugc-form-group {
    margin-bottom: 15px;
}

.ugc-form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.ugc-form-group input,
.ugc-form-group select,
.ugc-form-group textarea {
    width: 100%;
    padding: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.ugc-form-group input:focus,
.ugc-form-group select:focus,
.ugc-form-group textarea:focus {
    outline: none;
    border-color: var(--accent-ugc);
}

.ugc-form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.ugc-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.ugc-form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 5px;
}

.ugc-form-hint.warning {
    color: var(--warning);
}

/* Submit */
.ugc-submit-section {
    text-align: center;
    padding: 20px 0;
}

.ugc-submit-btn {
    padding: 14px 40px;
    background: linear-gradient(135deg, var(--accent-ugc), var(--accent));
    border: none;
    border-radius: 50px;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.ugc-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.3);
}

.ugc-submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.ugc-form-note {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 15px;
}

/* ============================================
   RIGHT SIDEBAR (HISTORY)
   ============================================ */

.sidebar-right {
    background: var(--bg-sidebar);
    border-left: 1px solid var(--border-color);
    display: flex; flex-direction: column;
    overflow: hidden;
    transition: width 0.3s ease;
}

.sidebar-right .sidebar-header { padding: 18px 15px; }
.sidebar-right .sidebar-header h3 { font-size: 1rem; font-weight: 600; }

.main-app.right-collapsed .sidebar-right { width: 0; border-left: none; overflow: hidden; }
.main-app.right-collapsed .sidebar-right .btn-collapse svg { transform: rotate(180deg); }

.history-tabs {
    display: flex; padding: 0 12px 12px; gap: 6px;
    flex-wrap: wrap;
}

.history-tab {
    flex: 1;
    padding: 8px 6px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    min-width: 70px;
}

.history-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.history-warning {
    padding: 10px 15px;
    background: rgba(245, 158, 11, 0.08);
    border-top: 1px solid rgba(245, 158, 11, 0.15);
    border-bottom: 1px solid rgba(245, 158, 11, 0.15);
    color: var(--warning);
    font-size: 0.7rem;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    -webkit-overflow-scrolling: touch;
}

.empty-history {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    height: 150px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.empty-history span { font-size: 2rem; margin-bottom: 8px; }

.history-item {
    display: flex; gap: 10px;
    padding: 10px;
    background: var(--bg-card);
    border-radius: 10px; margin-bottom: 8px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.history-item:hover { border-color: var(--border-color); }

.history-thumb {
    width: 55px; height: 55px;
    border-radius: 6px; object-fit: cover;
    background: var(--bg-input); flex-shrink: 0;
}

.history-thumb-placeholder {
    width: 55px; height: 55px;
    border-radius: 6px;
    background: var(--bg-input);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); font-size: 1.1rem;
    flex-shrink: 0;
}

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

.history-prompt {
    font-size: 0.8rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin-bottom: 5px;
}

.history-meta {
    display: flex; flex-wrap: wrap;
    gap: 5px; font-size: 0.65rem; color: var(--text-muted);
}

.status-dot {
    width: 5px; height: 5px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 3px;
}

.status-dot.completed { background: var(--success); }
.status-dot.failed { background: var(--error); }

/* ============================================
   MOBILE HEADER
   ============================================ */

.mobile-header {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-height);
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-color);
    padding: 0 12px;
    align-items: center; justify-content: space-between;
    z-index: 90;
}

.btn-header {
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    background: transparent; border: none;
    color: var(--text-secondary); border-radius: 10px;
    cursor: pointer;
}

.btn-header:hover { background: var(--bg-card); }
.btn-header svg { width: 22px; height: 22px; }

.mobile-title {
    display: flex; align-items: center; gap: 8px;
    font-weight: 600; font-size: 0.95rem;
}

#mobile-tool-icon { font-size: 1.2rem; }

.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 95; opacity: 0;
    transition: opacity 0.3s;
}

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

/* ============================================
   MEDIA MODAL
   ============================================ */

.media-modal {
    position: fixed; inset: 0;
    z-index: 500;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; visibility: hidden;
    transition: all 0.3s;
}

.media-modal.active { opacity: 1; visibility: visible; }

.media-modal .modal-backdrop {
    position: absolute; inset: 0;
    background: rgba(0, 0, 0, 0.9);
}

.media-modal .modal-content {
    position: relative;
    max-width: 90%; max-height: 85%;
    z-index: 1;
    display: flex; flex-direction: column; align-items: center;
}

.media-modal .modal-close {
    position: absolute;
    top: -42px; right: 0;
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.1);
    border: none; border-radius: 50%;
    color: white; cursor: pointer;
}

.media-modal .modal-close:hover { background: rgba(255,255,255,0.2); }
.media-modal .modal-close svg { width: 20px; height: 20px; }

#modal-image, #modal-video { max-width: 100%; max-height: 65vh; border-radius: 10px; }

.modal-actions {
    display: flex; justify-content: center;
    gap: 10px; margin-top: 18px;
}

.modal-btn {
    display: flex; align-items: center; gap: 7px;
    padding: 11px 22px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: white; font-size: 0.85rem;
    text-decoration: none; cursor: pointer;
    transition: all 0.2s;
}

.modal-btn:hover { background: var(--bg-input); }
.modal-btn.primary { background: var(--primary); border-color: var(--primary); }
.modal-btn.primary:hover { background: var(--primary-dark); }
.modal-btn svg { width: 16px; height: 16px; }

/* ============================================
   UGC RESULT MODAL
   ============================================ */

.ugc-modal-content {
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    background: var(--bg-card);
    border-radius: 16px;
    padding: 25px;
}

.ugc-modal-body h2 {
    font-size: 1.2rem;
    margin-bottom: 10px;
}

.ugc-status-badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 20px;
    background: var(--bg-input);
    color: var(--text-secondary);
}

.ugc-status-badge.completed { background: rgba(34, 197, 94, 0.2); color: var(--success); }
.ugc-status-badge.failed { background: rgba(239, 68, 68, 0.2); color: var(--error); }
.ugc-status-badge.processing { background: rgba(245, 158, 11, 0.2); color: var(--warning); }

.ugc-progress-section {
    margin-bottom: 20px;
}

.ugc-results-section {}

.ugc-result-group {
    margin-bottom: 20px;
}

.ugc-result-group h4 {
    font-size: 0.9rem;
    margin-bottom: 10px;
    color: var(--text-secondary);
}

.ugc-gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.ugc-gallery-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-input);
}

.ugc-gallery-item img,
.ugc-gallery-item video {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
}

.ugc-gallery-item a {
    position: absolute;
    bottom: 5px; right: 5px;
    padding: 4px 8px;
    background: rgba(0,0,0,0.7);
    border-radius: 4px;
    color: white;
    font-size: 0.65rem;
    text-decoration: none;
}

.ugc-final-video {
    width: 100%;
    border-radius: 10px;
    background: #000;
}

.ugc-audio {
    width: 100%;
}

.ugc-download-btn {
    display: inline-block;
    margin-top: 10px;
    padding: 8px 16px;
    background: var(--accent-ugc);
    border-radius: 8px;
    color: white;
    font-size: 0.8rem;
    text-decoration: none;
}

.ugc-script {
    background: var(--bg-input);
    padding: 15px;
    border-radius: 10px;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-secondary);
    white-space: pre-wrap;
}

.ugc-error-section {
    padding: 20px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 10px;
    color: #fca5a5;
    text-align: center;
}

/* ============================================
   SCROLLBAR
   ============================================ */

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1100px) {
    :root { --sidebar-right-width: 260px; }
}

@media (max-width: 900px) {
    .main-app { grid-template-columns: 1fr; }
    .mobile-header { display: flex; }
    .main-content { padding-top: var(--header-height); }
    
    .sidebar-left {
        position: fixed;
        left: -100%; top: 0;
        width: 260px; height: 100%;
        z-index: 100;
        transition: left 0.3s ease;
    }
    
    .sidebar-left.open { left: 0; }
    
    .main-app.left-collapsed .sidebar-left { width: 260px; }
    .main-app.left-collapsed .sidebar-left .logo-text,
    .main-app.left-collapsed .sidebar-left .user-info,
    .main-app.left-collapsed .sidebar-left .nav-text,
    .main-app.left-collapsed .sidebar-left .nav-badge,
    .main-app.left-collapsed .sidebar-left .nav-section-label,
    .main-app.left-collapsed .sidebar-left .btn-label { display: block; }
    
    .main-app.left-collapsed .sidebar-left .sidebar-header,
    .main-app.left-collapsed .sidebar-left .sidebar-user,
    .main-app.left-collapsed .sidebar-left .nav-item,
    .main-app.left-collapsed .sidebar-left .sidebar-footer,
    .main-app.left-collapsed .sidebar-left .upgrade-btn,
    .main-app.left-collapsed .sidebar-left .logout-btn {
        justify-content: flex-start;
        padding-left: 15px; padding-right: 15px;
    }
    
    .btn-collapse { display: none; }
    
    .sidebar-right {
        position: fixed;
        right: -100%; top: 0;
        width: 300px; max-width: 85%; height: 100%;
        z-index: 100;
        transition: right 0.3s ease;
    }
    
    .sidebar-right.open { right: 0; }
    .main-app.right-collapsed .sidebar-right { width: 300px; border-left: 1px solid var(--border-color); }
    
    .ugc-upload-row { grid-template-columns: 1fr; }
    .ugc-form-row { grid-template-columns: 1fr; }
}

@media (max-width: 500px) {
    .panel-inner { max-width: 100%; }
    .chat-area { padding: 15px; }
    .input-section { padding: 10px 12px; }
    
    .message { max-width: 92%; }
    .msg-media { max-width: 220px; }
    .welcome-icon { font-size: 3rem; }
    .welcome-box h2 { font-size: 1.2rem; }
    .chip { padding: 7px 11px; font-size: 0.75rem; }
    
    .ratio-btn { padding: 5px 9px; }
    .ratio-btn span { display: none; }
    
    .sidebar-right { width: 100%; max-width: 100%; }
    
    .ugc-gallery { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================
   FIX 1: ANIMASI TOMBOL GENERATE UGC
   ============================================ */

.ugc-submit-btn {
    position: relative;
    overflow: hidden;
    transform: translateY(0);
}

.ugc-submit-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.5s ease, height 0.5s ease;
}

.ugc-submit-btn:not(:disabled):hover::before {
    width: 400px;
    height: 400px;
}

.ugc-submit-btn:not(:disabled):active {
    transform: scale(0.97);
}

/* Loading State */
.ugc-submit-btn.loading {
    color: transparent;
    pointer-events: none;
}

.ugc-submit-btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 22px;
    height: 22px;
    margin: -11px 0 0 -11px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: btnSpin 0.8s linear infinite;
}

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

/* Success State */
.ugc-submit-btn.success {
    background: linear-gradient(135deg, var(--success), #16a34a) !important;
    animation: successPulse 0.5s ease;
}

@keyframes successPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* ============================================
   FIX 2: TOMBOL UNTUK MEMBUKA SIDEBAR RIWAYAT
   ============================================ */

.btn-expand-right {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 70px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-right: none;
    border-radius: 8px 0 0 8px;
    color: var(--text-muted);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 50;
    transition: all 0.2s;
}

.btn-expand-right:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    width: 36px;
}

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

.main-app.right-collapsed .btn-expand-right {
    display: flex;
}

/* ============================================
   FIX 3: HISTORY DENGAN PROGRESS UNTUK UGC
   ============================================ */

/* Section divider untuk Active vs Completed */
.history-section-label {
    padding: 8px 12px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.history-section-label.active {
    color: var(--warning);
    background: rgba(245, 158, 11, 0.08);
    border-radius: 8px 8px 0 0;
}

/* Active Job Card dengan Progress */
.history-item.processing {
    border: 1px solid rgba(245, 158, 11, 0.3);
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.05), transparent);
    animation: processingGlow 2s ease-in-out infinite;
}

@keyframes processingGlow {
    0%, 100% { box-shadow: 0 0 0 rgba(245, 158, 11, 0); }
    50% { box-shadow: 0 0 15px rgba(245, 158, 11, 0.15); }
}

.history-item.pending {
    border: 1px solid rgba(139, 92, 246, 0.3);
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.05), transparent);
}

/* Progress bar dalam history item */
.history-progress {
    margin-top: 8px;
}

.history-progress-track {
    height: 4px;
    background: var(--bg-input);
    border-radius: 2px;
    overflow: hidden;
}

.history-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--warning), var(--accent));
    border-radius: 2px;
    transition: width 0.3s ease;
    animation: progressShimmer 1.5s infinite;
}

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

.history-progress-text {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
    font-size: 0.65rem;
    color: var(--warning);
}

/* Loading dots animation untuk pending */
.history-loading-dots {
    display: inline-flex;
    gap: 3px;
    margin-left: 5px;
}

.history-loading-dots span {
    width: 4px;
    height: 4px;
    background: var(--warning);
    border-radius: 50%;
    animation: historyDotBounce 1.4s infinite;
}

.history-loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.history-loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes historyDotBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* Empty state untuk active jobs */
.empty-active {
    padding: 20px 15px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.empty-active span {
    font-size: 1.5rem;
    display: block;
    margin-bottom: 5px;
}

/* Responsive: Hide expand button on mobile */
@media (max-width: 900px) {
    .btn-expand-right {
        display: none !important;
    }
}
