/* ==========================================================================
   Modern Dark Glassmorphism Design System
   ========================================================================== */

:root {
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;

  --accent-primary: #6366f1;
  --accent-primary-hover: #4f46e5;
  --accent-secondary: #06b6d4;
  --accent-danger: #ef4444;
  --accent-danger-hover: #dc2626;
  --accent-success: #10b981;
}

/* Dark Theme Default */
body.theme-dark {
  --bg-base: #0c0e14;
  --bg-surface: #141721;
  --bg-surface-hover: #1c2130;
  --bg-glass: rgba(20, 24, 35, 0.78);
  --bg-glass-elevated: rgba(28, 34, 49, 0.88);

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.5);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);

  --card-bg: rgba(255, 255, 255, 0.025);
  --card-bg-hover: rgba(255, 255, 255, 0.055);
  --card-bg-selected: rgba(99, 102, 241, 0.15);
  --input-bg: rgba(255, 255, 255, 0.04);
  --input-bg-focus: rgba(255, 255, 255, 0.08);

  --radial-gradient: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(6, 182, 212, 0.08) 0px, transparent 50%);
}

/* Light Theme */
body.theme-light {
  --bg-base: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-hover: #f1f5f9;
  --bg-glass: rgba(255, 255, 255, 0.82);
  --bg-glass-elevated: rgba(255, 255, 255, 0.94);

  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-focus: rgba(99, 102, 241, 0.6);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 36px rgba(0, 0, 0, 0.12);

  --card-bg: rgba(0, 0, 0, 0.02);
  --card-bg-hover: rgba(0, 0, 0, 0.04);
  --card-bg-selected: rgba(99, 102, 241, 0.12);
  --input-bg: rgba(0, 0, 0, 0.04);
  --input-bg-focus: rgba(0, 0, 0, 0.02);

  --radial-gradient: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.08) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(6, 182, 212, 0.05) 0px, transparent 50%);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden;
  background-image: var(--radial-gradient);
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* Glassmorphism Panel */
.glass-panel {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
}

/* Base App Layout */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Sidebar */
.app-sidebar {
  width: 260px;
  min-width: 260px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-subtle);
  z-index: 10;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.brand-icon svg {
  width: 22px;
  height: 22px;
}

.brand-title {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  display: block;
}

.brand-sub {
  font-size: 0.75rem;
  color: var(--accent-success);
  display: flex;
  align-items: center;
  gap: 4px;
}

.brand-sub::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-success);
}

.sidebar-nav {
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 8px 12px;
  margin-top: 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all var(--transition-fast);
}

.nav-link svg {
  width: 18px;
  height: 18px;
  stroke: var(--text-muted);
  transition: stroke var(--transition-fast);
}

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

.nav-link:hover svg {
  stroke: var(--text-primary);
}

.nav-link.active {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.nav-link.active svg {
  stroke: #a5b4fc;
}

.sidebar-footer {
  padding: 16px 14px;
  border-top: 1px solid var(--border-subtle);
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: white;
}

.user-info {
  flex: 1;
  overflow: hidden;
}

.user-name {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Main Area */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Top Action Bar */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border-subtle);
  z-index: 5;
}

/* Breadcrumbs */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  white-space: nowrap;
  max-width: 40%;
  scrollbar-width: none;
}

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

.crumb-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.crumb-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.crumb-btn.active {
  color: var(--text-primary);
  font-weight: 600;
}

.crumb-sep {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Search Box */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
  width: 280px;
}

.search-icon {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  stroke: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 36px 8px 36px;
  color: var(--text-primary);
  font-size: 0.88rem;
  font-family: inherit;
  outline: none;
  transition: all var(--transition-fast);
}

.search-box input:focus {
  background: var(--input-bg-focus);
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

#search-clear {
  position: absolute;
  right: 10px;
  font-size: 1.2rem;
  line-height: 1;
}

/* Top Actions */
.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.view-toggle {
  display: flex;
  background: var(--input-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 2px;
}

.toggle-btn {
  background: transparent;
  border: none;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

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

.toggle-btn.active {
  background: var(--card-bg-hover);
  color: var(--text-primary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn.icon-only {
  padding: 8px 10px;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-primary-hover));
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--card-bg);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-subtle);
}

.icon-btn-ghost {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.icon-btn-ghost svg {
  width: 18px;
  height: 18px;
}

.icon-btn-ghost:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.upload-btn {
  cursor: pointer;
}

/* Dropzone */
.dropzone-banner {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(8px);
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--accent-primary);
  margin: 16px;
  border-radius: var(--radius-lg);
}

.dropzone-banner.active {
  display: flex;
}

.dropzone-content {
  text-align: center;
}

.dropzone-content svg {
  width: 56px;
  height: 56px;
  stroke: var(--accent-primary);
  margin-bottom: 12px;
}

/* Viewport */
.file-viewport {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.viewport-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding: 0 4px;
}

.toggle-control {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

/* Grid View */
.files-container.grid-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.file-card {
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
  position: relative;
}

.file-card:hover {
  background: var(--card-bg-hover);
  border-color: rgba(99, 102, 241, 0.4);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.file-card.selected {
  background: var(--card-bg-selected);
  border-color: var(--accent-primary);
}

.file-icon-wrap {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  border-radius: var(--radius-md);
}

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

.file-card .file-name {
  font-size: 0.88rem;
  font-weight: 500;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 4px;
}

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

/* List / Table View */
.files-container.list-view {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.files-container.list-view .file-card {
  flex-direction: row;
  align-items: center;
  text-align: left;
  padding: 10px 16px;
  gap: 16px;
  border-radius: var(--radius-sm);
}

.files-container.list-view .file-icon-wrap {
  width: 32px;
  height: 32px;
  margin-bottom: 0;
}

.files-container.list-view .file-icon-wrap svg {
  width: 20px;
  height: 20px;
}

.files-container.list-view .file-name {
  flex: 1;
  margin-bottom: 0;
}

.files-container.list-view .file-meta {
  width: 120px;
  text-align: right;
}

/* Icon Color Variants */
.icon-folder { color: #f59e0b; }
.icon-text { color: #3b82f6; }
.icon-image { color: #10b981; }
.icon-video { color: #8b5cf6; }
.icon-audio { color: #ec4899; }
.icon-archive { color: #eab308; }
.icon-pdf { color: #ef4444; }
.icon-generic { color: #94a3b8; }

/* Empty State */
.empty-state {
  margin: auto;
  text-align: center;
  padding: 40px;
  max-width: 400px;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.empty-state h3 {
  font-size: 1.1rem;
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 0.88rem;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-window {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-width: 90vw;
  animation: modalIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Editor Modal Window */
.editor-window {
  width: 900px;
  height: 80vh;
}

.modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
}

.editor-saved-pill {
  font-size: 0.75rem;
  color: var(--accent-success);
}

.editor-body {
  flex: 1;
  padding: 0;
}

#editor-textarea {
  width: 100%;
  height: 100%;
  border: none;
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  line-height: 1.6;
  padding: 20px;
  outline: none;
  resize: none;
}

/* Preview Modal Window */
.preview-window {
  max-width: 850px;
  max-height: 85vh;
}

.preview-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--card-bg);
}

.preview-body img,
.preview-body video {
  max-width: 100%;
  max-height: 70vh;
  border-radius: var(--radius-md);
}

.preview-body audio {
  width: 100%;
  min-width: 320px;
}

/* Prompt Modal */
.prompt-window {
  width: 420px;
}

.input-field {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  margin-top: 8px;
}

.input-field:focus {
  border-color: var(--border-focus);
}

/* Auth Card */
.auth-card {
  width: 380px;
  border-radius: var(--radius-xl);
  padding: 32px;
  box-shadow: var(--shadow-lg);
}

.auth-header {
  text-align: center;
  margin-bottom: 24px;
}

.brand-badge {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px auto;
  color: white;
}

.brand-badge svg {
  width: 28px;
  height: 28px;
}

.auth-header h2 {
  font-size: 1.4rem;
  margin-bottom: 6px;
}

.auth-header p {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.form-group {
  margin-bottom: 16px;
}

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

.btn-block {
  width: 100%;
  justify-content: center;
  padding: 12px;
  margin-top: 8px;
}

.form-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  font-size: 0.82rem;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  margin-bottom: 14px;
}

/* Context Menu */
.context-menu {
  position: fixed;
  z-index: 1000;
  min-width: 180px;
  border-radius: var(--radius-md);
  padding: 6px;
  box-shadow: var(--shadow-md);
}

.ctx-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition-fast);
}

.ctx-item svg {
  width: 16px;
  height: 16px;
  stroke: var(--text-secondary);
}

.ctx-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.ctx-item.danger {
  color: #fca5a5;
}

.ctx-item.danger svg {
  stroke: #ef4444;
}

.ctx-item.danger:hover {
  background: rgba(239, 68, 68, 0.15);
}

.ctx-separator {
  height: 1px;
  background: var(--border-subtle);
  margin: 4px 0;
}

.hidden {
  display: none !important;
}
