:root {
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #334155;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #818cf8;
    --primary-hover: #6366f1;
    --success: #22c55e;
    --error: #ef4444;
    --border: #334155;
    --radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
}

/* Utils */
.hidden { display: none !important; }
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

/* Login */
.login-card {
    width: 100%;
    max-width: 400px;
    text-align: center;
    padding: 2.5rem;
}

.login-card h2 { margin-bottom: 0.5rem; }
.login-card p { color: var(--text-muted); margin-bottom: 1.5rem; }
.login-card input {
    width: 100%;
    padding: 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: white;
    margin-bottom: 1rem;
    font-size: 1rem;
}

.error-text { color: var(--error); font-size: 0.875rem; margin-top: 0.5rem; }

/* Layout */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.logo { display: flex; align-items: center; gap: 0.75rem; }
.logo h1 { font-size: 1.5rem; font-weight: 800; }
.logo span { color: var(--primary); }

.grid-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 2rem;
}

@media (max-width: 900px) {
    .grid-layout { grid-template-columns: 1fr; }
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

/* Sidebar & Upload */
.drop-zone {
    border: 2px dashed var(--border);
    text-align: center;
    padding: 3rem 1.5rem;
    transition: all 0.2s;
    cursor: pointer;
}

.drop-zone:hover { border-color: var(--primary); background: #1e293b80; }
.upload-icon { font-size: 2.5rem; display: block; margin-bottom: 1rem; }
.file-info { margin-top: 1rem; color: var(--primary); font-weight: 600; }

/* Content Area */
.text-content {
    background: var(--bg-main);
    padding: 1rem;
    border-radius: var(--radius);
    height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border);
    font-size: 0.95rem;
    line-height: 1.7;
    color: #cbd5e1;
}

/* Chat */
.chat-card { display: flex; flex-direction: column; margin-top: 2rem; }
.chat-history {
    height: 300px;
    overflow-y: auto;
    padding: 1rem;
    background: var(--bg-main);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-message {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    max-width: 80%;
    font-size: 0.9rem;
}

.ai-msg { background: var(--bg-input); color: white; align-self: flex-start; border-bottom-left-radius: 2px; }
.user-msg { background: var(--primary); color: white; align-self: flex-end; border-bottom-right-radius: 2px; }

.chat-input-wrapper { display: flex; gap: 0.5rem; }
.chat-input-wrapper input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    color: white;
}

/* Buttons */
button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    font-weight: 600;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary { background: var(--primary); color: white; padding: 0.75rem 1.5rem; border-radius: var(--radius); }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }

.btn-success { background: var(--success); color: white; width: 100%; padding: 1rem; border-radius: var(--radius); margin-top: 1rem; }
.btn-success:disabled { opacity: 0.3; cursor: not-allowed; }

.btn-ghost { background: transparent; color: var(--text-muted); padding: 0.5rem 1rem; }
.btn-ghost:hover { color: white; }

.btn-outline { background: transparent; border: 1px solid var(--border); color: white; padding: 0.5rem 1rem; border-radius: var(--radius); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.btn-small { background: var(--bg-input); color: var(--text-muted); padding: 0.4rem 0.8rem; border-radius: 6px; font-size: 0.75rem; }
.btn-small:hover { color: white; }

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 400px;
    color: var(--text-muted);
}

.empty-icon { font-size: 4rem; margin-bottom: 1rem; opacity: 0.2; }

/* Loading Spinner */
.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1.5rem;
}

.loader-content {
    text-align: center;
    width: 90%;
    max-width: 400px;
}

.progress-container {
    width: 100%;
    height: 8px;
    background: var(--bg-input);
    border-radius: 10px;
    margin: 1.5rem 0;
    overflow: hidden;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background: var(--primary);
    transition: width 0.3s ease;
}

/* Header Storage */
.header-storage {
    width: 220px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.storage-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.header-storage .storage-info {
    justify-content: flex-end;
    font-size: 0.7rem;
    margin-top: 2px;
}

.storage-bar-container {
    height: 8px;
    background: var(--bg-main);
    border-radius: 10px;
    overflow: hidden;
}

.storage-bar-fill {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.3s ease;
}

@media (max-width: 1000px) {
    .header-storage { width: 150px; }
    .storage-label { font-size: 0.65rem; }
}

@media (max-width: 850px) {
    .header-storage { display: none; }
}

/* Tabs */
.app-tabs {
    display: flex;
    gap: 1rem;
    background: var(--bg-card);
    padding: 0.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.tab-btn {
    background: transparent;
    color: var(--text-muted);
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-size: 0.9rem;
}

.tab-btn.active {
    background: var(--primary);
    color: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: grid;
}

#gallery-tab.active {
    display: block;
}

/* Gallery Grid */
.gallery-full-card {
    min-height: 600px;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.media-card-item {
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
}

.media-card-item:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
}

.media-thumb {
    height: 160px;
    background: #0f172a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    cursor: pointer;
    position: relative;
}

.media-thumb::after {
    content: '▶';
    position: absolute;
    font-size: 1.5rem;
    background: rgba(129, 140, 248, 0.8);
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s;
}

.media-thumb:hover::after {
    opacity: 1;
}

.media-card-info {
    padding: 1.25rem;
    flex: 1;
}

.media-card-name {
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.media-card-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.media-card-actions {
    display: flex;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    background: rgba(255, 255, 255, 0.02);
    border-top: 1px solid var(--border);
}

.media-card-actions button, .media-card-actions a {
    flex: 1;
}

/* Modal Video */
.video-modal-content {
    background: var(--bg-card);
    width: 90%;
    max-width: 1000px;
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
}

.modal-header {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.btn-close {
    background: transparent;
    color: var(--text-muted);
    font-size: 1.5rem;
}

.video-container {
    width: 100%;
    aspect-ratio: 16/9;
    background: black;
}

.video-container video {
    width: 100%;
    height: 100%;
}

@keyframes spin { to { transform: rotate(360deg); } }
