/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface2: #242836;
    --border: #2e3345;
    --text: #e4e7f0;
    --text2: #8b90a0;
    --primary: #6c8cff;
    --primary-hover: #859eff;
    --danger: #ff6b6b;
    --danger-hover: #ff8585;
    --success: #4ecdc4;
    --radius: 8px;
    --radius-lg: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* === Auth Page === */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}

.auth-container { width: 100%; max-width: 400px; }

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
}

.auth-logo {
    text-align: center;
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.auth-logo h1 {
    font-size: 1.5rem;
    margin-top: 0.5rem;
    color: var(--text);
}

.auth-subtitle {
    text-align: center;
    color: var(--text2);
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

/* === Forms === */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.4rem;
    color: var(--text2);
}

.form-group input {
    width: 100%;
    padding: 0.7rem 0.9rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.15s;
}

.form-group input:focus {
    border-color: var(--primary);
}

.error-msg {
    color: var(--danger);
    font-size: 0.85rem;
    min-height: 1.25rem;
    margin-bottom: 0.5rem;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn-full { width: 100%; padding: 0.75rem; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.btn-icon {
    padding: 0.5rem;
    background: transparent;
    border: none;
    color: var(--text2);
    cursor: pointer;
    border-radius: var(--radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-icon:hover { background: var(--surface2); color: var(--text); }

/* === Dashboard Layout === */
.dashboard {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Top bar */
.topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary);
    font-weight: 600;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.topbar-logo svg { width: 24px; height: 24px; }

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex: 1;
    overflow-x: auto;
    font-size: 0.9rem;
    padding: 0.25rem 0;
}

.breadcrumbs a {
    color: var(--text2);
    text-decoration: none;
    white-space: nowrap;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
}

.breadcrumbs a:hover { background: var(--surface2); color: var(--text); }
.breadcrumbs a.active { color: var(--text); font-weight: 500; }
.breadcrumbs .sep { color: var(--text2); opacity: 0.5; flex-shrink: 0; }

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

/* File list */
.file-area {
    flex: 1;
    padding: 1rem 1.5rem;
}

.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
}

.file-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    position: relative;
    text-align: center;
    word-break: break-word;
}

.file-item:hover { border-color: var(--primary); background: var(--surface2); }

.file-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text2);
}

.file-icon.folder { color: var(--primary); }

.file-icon svg { width: 40px; height: 40px; }

.file-name {
    font-size: 0.85rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.file-meta {
    font-size: 0.75rem;
    color: var(--text2);
}

.file-actions {
    position: absolute;
    top: 0.35rem;
    right: 0.35rem;
    opacity: 0;
    transition: opacity 0.15s;
}

.file-item:hover .file-actions { opacity: 1; }

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 1rem;
    color: var(--text2);
    text-align: center;
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    opacity: 0.4;
}

.empty-state p { margin-bottom: 0.5rem; }

/* Drop zone */
.drop-overlay {
    position: fixed;
    inset: 0;
    background: rgba(108, 140, 255, 0.08);
    border: 3px dashed var(--primary);
    z-index: 999;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--primary);
    font-weight: 600;
    pointer-events: none;
}

.drop-overlay.active { display: flex; }

/* Context menu */
.context-menu {
    position: fixed;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.35rem;
    min-width: 160px;
    z-index: 200;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    display: none;
}

.context-menu.active { display: block; }

.context-menu button {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: none;
    border: none;
    color: var(--text);
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: 4px;
    text-align: left;
}

.context-menu button:hover { background: var(--surface2); }
.context-menu button.danger { color: var(--danger); }
.context-menu button.danger:hover { background: rgba(255,107,107,0.1); }
.context-menu .separator { height: 1px; background: var(--border); margin: 0.25rem 0; }

/* Upload progress */
.upload-progress {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    min-width: 280px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    z-index: 150;
    display: none;
}

.upload-progress.active { display: block; }

.upload-progress-title {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.upload-progress-bar {
    height: 4px;
    background: var(--surface2);
    border-radius: 2px;
    overflow: hidden;
}

.upload-progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    transition: width 0.3s;
    width: 0%;
}

.upload-progress-text {
    font-size: 0.75rem;
    color: var(--text2);
    margin-top: 0.35rem;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 300;
    padding: 1rem;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    width: 100%;
    max-width: 400px;
}

.modal h3 { margin-bottom: 1rem; font-size: 1.1rem; }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.25rem;
}

/* Responsive */
@media (max-width: 640px) {
    .topbar { padding: 0.6rem 1rem; }
    .toolbar { padding: 0.6rem 1rem; }
    .file-area { padding: 0.75rem; }
    .file-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 0.5rem;
    }
    .auth-card { padding: 1.75rem; }
    .topbar-logo span { display: none; }
}

@media (max-width: 400px) {
    .file-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
