/* ===== VARIABLES (DARK MODE DEFAULT) ===== */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a24;
    --bg-elevated: #20202c;
    --bg-hover: #26263380;
    --border: #2a2a36;
    --border-light: #353543;
    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --text-tertiary: #71717a;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.4);
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --instagram: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.4);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* LIGHT MODE */
[data-theme="light"] {
    --bg-primary: #fafafa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f4f4f5;
    --bg-elevated: #ffffff;
    --bg-hover: #f4f4f580;
    --border: #e4e4e7;
    --border-light: #f4f4f5;
    --text-primary: #09090b;
    --text-secondary: #52525b;
    --text-tertiary: #a1a1aa;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.12);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    transition: background 0.3s, color 0.3s;
}

.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

/* ===== LOGIN SCREEN ===== */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.auth-bg {
    position: absolute;
    inset: 0;
    background: 
        radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(168, 85, 247, 0.15) 0%, transparent 40%),
        var(--bg-primary);
    z-index: 0;
}

.login-card {
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    padding: 40px 32px;
    box-shadow: var(--shadow-lg);
    text-align: center;
    max-width: 420px;
    width: 100%;
    position: relative;
    z-index: 1;
    border: 1px solid var(--border);
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.logo { margin-bottom: 20px; }

.logo-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--accent), #a855f7);
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    margin-bottom: 16px;
    box-shadow: 0 8px 24px var(--accent-glow);
}

.logo h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 28px;
    font-size: 14px;
}

/* Tabs */
.auth-tabs {
    display: flex;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 24px;
}

.tab-btn {
    flex: 1;
    padding: 9px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition);
}

.tab-btn.active {
    background: var(--bg-elevated);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

/* Forms */
.auth-form {
    display: none;
    text-align: left;
}

.auth-form.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.input-group {
    position: relative;
    margin-bottom: 14px;
}

.input-group input {
    width: 100%;
    padding: 15px 42px 15px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--bg-tertiary);
    outline: none;
    transition: var(--transition);
    color: var(--text-primary);
    font-family: inherit;
}

.input-group input:focus {
    border-color: var(--accent);
    background: var(--bg-elevated);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-group label {
    position: absolute;
    left: 14px;
    top: 15px;
    font-size: 14px;
    color: var(--text-tertiary);
    pointer-events: none;
    transition: var(--transition);
    padding: 0;
}

.input-group input:focus + label,
.input-group input:not(:placeholder-shown) + label {
    top: -8px;
    left: 10px;
    font-size: 11px;
    background: var(--bg-elevated);
    padding: 0 6px;
    color: var(--accent);
    font-weight: 600;
}

.toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    padding: 4px;
    transition: var(--transition);
}

.toggle-password:hover { color: var(--text-primary); }

.form-error {
    font-size: 12px;
    color: var(--error);
    margin-bottom: 8px;
    min-height: 18px;
    font-weight: 500;
}

.primary-btn {
    width: 100%;
    padding: 13px 20px;
    background: var(--accent);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    margin-top: 8px;
    transition: var(--transition);
    box-shadow: 0 4px 12px var(--accent-glow);
    position: relative;
}

.primary-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px var(--accent-glow);
}

.primary-btn:disabled {
    background: var(--bg-tertiary);
    color: var(--text-tertiary);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Divider */
.divider {
    position: relative;
    text-align: center;
    margin: 22px 0;
    color: var(--text-tertiary);
    font-size: 11px;
    font-weight: 500;
}

.divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border);
}

.divider span {
    background: var(--bg-elevated);
    padding: 0 12px;
    position: relative;
}

.google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    transition: var(--transition);
}

.google-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
}

.google-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ===== DASHBOARD ===== */
.dashboard { min-height: 100vh; }

/* Navbar */
.navbar {
    height: 64px;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
}

.nav-left { display: flex; align-items: center; gap: 14px; flex: 1; }

.menu-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: var(--transition);
}

.menu-icon:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.brand-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent), #a855f7);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.nav-center { flex: 2; max-width: 600px; margin: 0 auto; }

.search-box {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: var(--transition);
    color: var(--text-secondary);
    border: 1px solid transparent;
}

.search-box:focus-within {
    background: var(--bg-elevated);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-box input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 13px;
    color: var(--text-primary);
    font-family: inherit;
}

.search-box input::placeholder { color: var(--text-tertiary); }

.nav-right { display: flex; align-items: center; gap: 10px; flex: 1; justify-content: flex-end; }

.theme-toggle {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: var(--transition);
}

.theme-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

[data-theme="light"] .sun-icon { display: none; }
[data-theme="dark"] .theme-toggle::before {
    content: '☀️';
}
[data-theme="dark"] .sun-icon { display: none; }

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #a855f7);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    overflow: hidden;
}

.user-avatar img { width: 100%; height: 100%; object-fit: cover; }

.user-name { font-size: 13px; color: var(--text-primary); font-weight: 500; }

.logout-btn {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.logout-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-light);
}

/* Main layout */
.main-wrapper { display: flex; min-height: calc(100vh - 64px); }

/* Sidebar */
.sidebar {
    width: 240px;
    background: var(--bg-secondary);
    padding: 20px 12px;
    transition: transform 0.3s ease;
    border-right: 1px solid var(--border);
    flex-shrink: 0;
}

.new-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 14px;
    background: var(--accent);
    border-radius: var(--radius-sm);
    color: white;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 24px;
    transition: var(--transition);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.new-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px var(--accent-glow);
}

.new-btn span { color: white; }

.sidebar-menu { list-style: none; padding: 0; }

.sidebar-menu li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    transition: var(--transition);
    margin: 2px 0;
    font-weight: 500;
}

.sidebar-menu li:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-menu li.active {
    background: var(--bg-hover);
    color: var(--accent);
}

.sidebar-menu li svg { flex-shrink: 0; }

.storage-info {
    margin: 20px 12px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-secondary);
}

.storage-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-weight: 500;
}

.storage-bar {
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    margin-bottom: 6px;
    overflow: hidden;
}

.storage-used {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.3s;
    border-radius: 2px;
}

/* Content */
.content {
    flex: 1;
    padding: 28px;
    overflow-y: auto;
    background: var(--bg-primary);
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.content-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.view-toggle {
    display: flex;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.view-toggle button {
    width: 36px;
    height: 36px;
    color: var(--text-secondary);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.view-toggle button.active {
    background: var(--bg-hover);
    color: var(--accent);
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 32px 20px;
    text-align: center;
    background: var(--bg-secondary);
    margin-bottom: 28px;
    cursor: pointer;
    transition: var(--transition);
}

.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--accent);
    background: var(--bg-tertiary);
    transform: scale(1.005);
}

.drop-zone-content { display: flex; flex-direction: column; align-items: center; }

.upload-icon {
    width: 56px;
    height: 56px;
    background: var(--bg-tertiary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    margin-bottom: 12px;
    transition: var(--transition);
}

.drop-zone:hover .upload-icon {
    background: var(--accent);
    color: white;
    transform: translateY(-2px);
}

.drop-text {
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
}

.link-text {
    color: var(--accent);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.upload-hint {
    margin-top: 6px;
    color: var(--text-tertiary);
    font-size: 12px;
}

/* Files Grid */
.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.files-grid.list-view {
    grid-template-columns: 1fr;
    gap: 4px;
}

.file-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: var(--transition);
    cursor: pointer;
    animation: fadeIn 0.3s ease;
}

.file-card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.file-thumbnail {
    width: 100%;
    height: 140px;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.file-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.file-icon-large { font-size: 48px; }

.instagram-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--instagram);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.3px;
    backdrop-filter: blur(8px);
}

.file-info {
    padding: 12px;
}

.file-name {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.file-meta {
    font-size: 11px;
    color: var(--text-tertiary);
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
}

.file-actions {
    display: flex;
    gap: 4px;
}

.action-btn {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    border-radius: 6px;
    font-size: 10px;
    color: var(--text-secondary);
    font-weight: 600;
    transition: var(--transition);
}

.action-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
    color: var(--text-primary);
}

.action-btn.instagram-toggle.marked {
    background: var(--instagram);
    color: white;
    border: none;
}

.action-btn.delete:hover {
    background: var(--error);
    color: white;
    border-color: var(--error);
}

/* List View */
.files-grid.list-view .file-card {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
}

.files-grid.list-view .file-thumbnail {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    flex-shrink: 0;
}

.files-grid.list-view .file-icon-large { font-size: 22px; }

.files-grid.list-view .file-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 16px;
}

.files-grid.list-view .file-meta { margin: 0; gap: 16px; flex: 0 0 auto; }

.files-grid.list-view .file-actions { width: 280px; flex: 0 0 auto; }

.files-grid.list-view .instagram-badge { position: static; }

/* Empty State */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-secondary);
}

.empty-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 16px;
    background: var(--bg-secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
}

.empty-state h3 {
    margin-bottom: 6px;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 16px;
}

.empty-state p { font-size: 13px; }

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(8px);
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.modal-header h3 {
    margin-bottom: 20px;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.progress-item {
    margin-bottom: 10px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.progress-name {
    font-size: 12px;
    color: var(--text-primary);
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.progress-bar {
    height: 4px;
    background: var(--bg-primary);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.3s;
    border-radius: 2px;
}

.progress-status {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 6px;
    font-weight: 500;
}

/* Preview Modal */
.preview-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    padding: 0;
    overflow: hidden;
    background: var(--bg-primary);
}

.close-preview {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    backdrop-filter: blur(8px);
    transition: var(--transition);
}

.close-preview:hover { background: rgba(0, 0, 0, 0.9); }

#preview-body {
    text-align: center;
    min-height: 200px;
}

#preview-body img,
#preview-body video {
    max-width: 100%;
    max-height: 85vh;
    display: block;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-elevated);
    color: var(--text-primary);
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    font-size: 13px;
    font-weight: 500;
    transition: transform 0.3s;
    z-index: 2000;
    border: 1px solid var(--border);
    max-width: 90vw;
    text-align: center;
}

.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--error); color: white; border-color: var(--error); }
.toast.success { background: var(--success); color: white; border-color: var(--success); }

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        height: calc(100vh - 64px);
        z-index: 50;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }
    .sidebar.show { transform: translateX(0); }
    .nav-center { display: none; }
    .user-name { display: none; }
    .logout-btn span { display: none; }
    .logout-btn { padding: 8px; }
    .files-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
    .content { padding: 16px; }
    .login-card { padding: 32px 24px; }
}
