/* ==========================================================================
   Hugging Face Cloudflare Pages Indexer - Modern Theme & Design Tokens
   ========================================================================== */

:root {
  /* Color Palette - Premium Edge Dark Mode */
  --bg-primary: #0b0f17;
  --bg-secondary: #131926;
  --bg-tertiary: #1c2436;
  --bg-card: rgba(23, 31, 46, 0.75);
  --bg-card-hover: rgba(33, 44, 66, 0.85);

  --border-color: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(99, 102, 241, 0.4);

  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  /* Accent Colors */
  --accent-primary: #6366f1; /* Indigo */
  --accent-primary-hover: #4f46e5;
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);

  --color-folder: #fbbf24; /* Amber */
  --color-image: #ec4899;  /* Pink */
  --color-code: #3b82f6;   /* Blue */
  --color-audio: #10b981;  /* Emerald */
  --color-video: #8b5cf6;  /* Purple */
  --color-archive: #f97316;/* Orange */
  --color-pdf: #ef4444;    /* Red */

  /* UI Tokens */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.25);

  --glass-bg: rgba(19, 25, 38, 0.8);
  --glass-blur: blur(12px);

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Variables */
html.light {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-card-hover: #f1f5f9;

  --border-color: rgba(0, 0, 0, 0.08);
  --border-highlight: rgba(99, 102, 241, 0.5);

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;

  --glass-bg: rgba(255, 255, 255, 0.85);
  --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.08);
}

/* Base Reset & Typography */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.5;
  overflow-x: hidden;
  min-height: 100vh;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* App Container Layout */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Header */
.app-header {
  height: 64px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-main);
}

.logo-icon-bg {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.2rem;
  box-shadow: var(--shadow-glow);
}

.brand-title-group {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  background: linear-gradient(to right, #ffffff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--accent-primary);
  letter-spacing: 0.05em;
}

/* Repo Selector Inputs */
.header-center {
  flex: 1;
  max-width: 580px;
  margin: 0 24px;
}

.repo-input-wrapper {
  display: flex;
  align-items: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 4px 6px;
  transition: var(--transition-normal);
}

.repo-input-wrapper:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

#repo-type-select {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
  outline: none;
}

#repo-type-select option {
  background: var(--bg-secondary);
  color: var(--text-main);
}

.input-divider {
  width: 1px;
  height: 20px;
  background: var(--border-color);
}

#repo-id-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 0.9rem;
  padding: 6px 12px;
  outline: none;
  font-family: 'JetBrains Mono', monospace;
}

/* Header Right Buttons */
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: var(--transition-fast);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.icon-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-main);
  border-color: var(--border-color);
}

.icon-btn-sm {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}

.icon-btn-sm:hover {
  color: var(--text-main);
  background: var(--bg-tertiary);
}

/* Main Body Layout */
.main-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Toolbar & Breadcrumbs */
.toolbar-bar {
  padding: 12px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.breadcrumb-container {
  overflow-x: auto;
  white-space: nowrap;
}

.breadcrumb-list {
  display: flex;
  align-items: center;
  list-style: none;
  gap: 6px;
  font-size: 0.9rem;
}

.breadcrumb-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
}

.breadcrumb-list li::after {
  content: "/";
  color: var(--text-dim);
}

.breadcrumb-list li:last-child::after {
  content: "";
}

.breadcrumb-list a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.breadcrumb-list a:hover {
  background: var(--bg-tertiary);
  color: var(--accent-primary);
}

.breadcrumb-list li:last-child a {
  color: var(--text-main);
  font-weight: 600;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.filter-input-box {
  display: flex;
  align-items: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 4px 10px;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.filter-input-box input {
  background: transparent;
  border: none;
  color: var(--text-main);
  outline: none;
  font-size: 0.85rem;
  width: 160px;
}

.clear-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}

.sort-dropdown-container select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 0.85rem;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  outline: none;
  cursor: pointer;
}

/* Explorer & Details Split Layout */
.explorer-wrapper {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

.file-view-container {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  position: relative;
}

/* Grid Mode Layout */
.file-grid.grid-mode {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

/* List Mode Layout */
.file-grid.list-mode {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* File Card Items */
.file-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: var(--transition-normal);
  position: relative;
}

.file-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-highlight);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.file-card.selected {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.4);
}

.card-icon-wrapper {
  font-size: 2.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.folder-icon { color: var(--color-folder); }
.image-icon { color: var(--color-image); }
.code-icon { color: var(--color-code); }
.audio-icon { color: var(--color-audio); }
.video-icon { color: var(--color-video); }
.archive-icon { color: var(--color-archive); }
.pdf-icon { color: var(--color-pdf); }

.card-title {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-main);
  word-break: break-all;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* List Mode Custom Styling */
.file-grid.list-mode .file-card {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
}

.file-grid.list-mode .card-icon-wrapper {
  font-size: 1.4rem;
  width: 32px;
}

.file-grid.list-mode .card-title {
  flex: 1;
  margin: 0 16px;
  -webkit-line-clamp: 1;
}

/* Details Panel Drawer */
.details-panel {
  width: 320px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: var(--transition-normal);
}

.details-panel.hidden-panel {
  display: none;
}

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

.panel-content {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-empty-placeholder {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 10px;
}

.panel-empty-placeholder i {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.4;
}

/* States (Loading, Empty, Error) */
.state-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
  color: var(--text-muted);
}

.spinner {
  width: 42px;
  height: 42px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

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

.empty-icon, .error-icon {
  font-size: 3.5rem;
  margin-bottom: 16px;
  opacity: 0.6;
}

.error-icon { color: var(--color-pdf); }

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 960px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.modal-sm {
  max-width: 460px;
}

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

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 1rem;
}

.modal-size-tag {
  font-size: 0.75rem;
  background: var(--bg-tertiary);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  color: var(--text-muted);
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-body img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: var(--radius-md);
}

.modal-body video, .modal-body audio {
  width: 100%;
  border-radius: var(--radius-md);
}

.modal-body pre {
  width: 100%;
  max-height: 65vh;
  overflow: auto;
  border-radius: var(--radius-md);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  color: var(--text-main);
  outline: none;
  font-size: 0.9rem;
}

.form-control:focus {
  border-color: var(--accent-primary);
}

.form-text {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 4px;
}

/* Footer */
.app-footer {
  height: 40px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 12px;
}

.app-footer a {
  color: var(--accent-primary);
  text-decoration: none;
}

.hidden {
  display: none !important;
}

/* Dropzone Styling */
.dropzone {
  border: 2px dashed var(--border-highlight);
  border-radius: var(--radius-md);
  padding: 30px 20px;
  text-align: center;
  background: var(--bg-tertiary);
  cursor: pointer;
  transition: var(--transition-fast);
}

.dropzone:hover, .dropzone.dragover {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
}

.dropzone-icon {
  font-size: 2.5rem;
  color: var(--accent-primary);
  margin-bottom: 10px;
}

.flex-col {
  flex-direction: column !important;
}

/* Responsive Breakpoints */
@media (max-width: 768px) {
  .app-header {
    padding: 0 12px;
  }
  .header-center {
    margin: 0 8px;
  }
  .details-panel {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 50;
  }
}

/* Login Screen Overlay */
.login-screen-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: var(--glass-blur);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 36px 30px;
  box-shadow: var(--shadow-md), var(--shadow-glow);
  text-align: center;
}

.login-header {
  margin-bottom: 24px;
}

.login-icon {
  width: 60px;
  height: 60px;
  margin: 0 auto 16px auto;
  border-radius: 50%;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: #fff;
  box-shadow: var(--shadow-glow);
}

.login-header h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

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

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon i {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  font-size: 1rem;
}

.input-with-icon input {
  width: 100%;
  padding: 12px 14px 12px 42px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition-fast);
}

.input-with-icon input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.login-error {
  color: var(--color-pdf);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 10px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-block {
  width: 100%;
  padding: 12px;
  font-size: 0.95rem;
}
