/* files.css — Professional SaaS File Manager Styles */
/* Dark mode friendly, responsive, modern design */

/* ===============================
   Layout
   =============================== */

.files-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 28px;
  min-height: calc(100vh - 200px);
}

/* ===============================
   Sidebar
   =============================== */

.files-sidebar {
  background: linear-gradient(160deg, rgba(15, 23, 42, 0.95), rgba(15, 23, 42, 0.65));
  border-radius: 18px;
  padding: 22px;
  height: fit-content;
  position: sticky;
  top: 30px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow: 0 25px 60px rgba(2, 6, 23, 0.55);
}

.files-sidebar-header {
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 16px;
}

.files-sidebar-header h3 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.files-categories {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.files-category-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: none;
  background: rgba(15, 23, 42, 0.4);
  color: rgba(226, 232, 240, 0.85);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
}

.files-category-btn:hover {
  background: rgba(56, 189, 248, 0.15);
  color: #f8fafc;
}

.files-category-btn.active {
  background: linear-gradient(130deg, rgba(14, 165, 233, 0.5), rgba(99, 102, 241, 0.5));
  color: #f8fafc;
  box-shadow: 0 12px 28px rgba(14, 165, 233, 0.35);
}

.category-icon {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
}

.category-label {
  flex: 1;
}

.category-count {
  font-size: 0.75rem;
  background: rgba(148, 163, 184, 0.2);
  padding: 2px 8px;
  border-radius: 10px;
  min-width: 24px;
  text-align: center;
}

.files-category-btn.active .category-count {
  background: rgba(248, 250, 252, 0.25);
}

/* ===============================
   Main Content Area
   =============================== */

.files-main-content {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ===============================
   Hero Surface
   =============================== */

.files-hero {
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
  padding: 32px;
  border-radius: 28px;
  background:
    radial-gradient(circle at top right, rgba(56, 189, 248, 0.25), transparent 55%),
    linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(15, 23, 42, 0.7));
  border: 1px solid rgba(148, 163, 184, 0.18);
  box-shadow: 0 40px 70px rgba(2, 6, 23, 0.55);
}

.files-hero-copy {
  flex: 1 1 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.files-hero-overline {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 12px;
  color: rgba(148, 163, 184, 0.9);
  margin: 0;
}

.files-hero-copy h2 {
  margin: 0;
  font-size: 32px;
  color: #f1f5f9;
}

.files-hero-copy p {
  margin: 0;
  color: rgba(226, 232, 240, 0.85);
  line-height: 1.6;
}

.files-hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.files-hero-tags span {
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  color: rgba(226, 232, 240, 0.8);
}

.files-hero-metrics {
  flex: 1 1 280px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}

.files-metric-card {
  padding: 18px;
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid rgba(148, 163, 184, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.files-metric-card p {
  margin: 0 0 6px;
  font-size: 13px;
  color: rgba(148, 163, 184, 0.9);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.files-metric-card h3 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  color: #f8fafc;
}

.files-metric-card small {
  display: block;
  margin-top: 4px;
  color: rgba(148, 163, 184, 0.85);
}

/* ===============================
   Smart Filters
   =============================== */

.files-quick-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filter-chip {
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.6);
  padding: 6px 16px;
  color: rgba(226, 232, 240, 0.9);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-chip:hover {
  border-color: rgba(56, 189, 248, 0.65);
  color: #e0f2fe;
}

.filter-chip.active {
  background: linear-gradient(120deg, rgba(59, 130, 246, 0.38), rgba(14, 165, 233, 0.38));
  border-color: rgba(56, 189, 248, 0.8);
  color: #f8fafc;
  box-shadow: 0 6px 18px rgba(14, 165, 233, 0.3);
}

/* ===============================
   Upload Section
   =============================== */

.files-upload-section {
  position: relative;
}

.files-upload-area {
  border: 1px dashed rgba(56, 189, 248, 0.4);
  border-radius: 20px;
  padding: 48px;
  text-align: center;
  background:
    linear-gradient(135deg, rgba(56, 189, 248, 0.12), rgba(99, 102, 241, 0.08)),
    rgba(15, 23, 42, 0.65);
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.08);
}

.files-upload-area:hover {
  border-color: rgba(56, 189, 248, 0.7);
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.3);
}

.files-upload-area.drag-over {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  transform: scale(1.01);
}

.files-upload-icon {
  margin-bottom: 16px;
  color: #38bdf8;
}

.files-upload-icon svg {
  width: 48px;
  height: 48px;
}

.files-upload-area h3 {
  margin: 0 0 8px;
  color: #f8fafc;
  font-size: 1.15rem;
  font-weight: 600;
}

.files-upload-area p {
  margin: 0 0 20px;
  color: rgba(226, 232, 240, 0.8);
  font-size: 0.95rem;
}

.files-upload-progress {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.9);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 10;
}

.progress-bar {
  width: 80%;
  max-width: 400px;
  height: 8px;
  background: rgba(148, 163, 184, 0.25);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8 0%, #6366f1 100%);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.progress-text {
  font-weight: 500;
  color: #f8fafc;
}

/* ===============================
   Toolbar
   =============================== */

.files-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-radius: 20px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(148, 163, 184, 0.15);
  box-shadow: 0 25px 60px rgba(2, 6, 23, 0.45);
}

.files-toolbar-left,
.files-toolbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.files-search-box {
  position: relative;
  flex: 1;
  min-width: 260px;
}

.files-search-box svg {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(148, 163, 184, 0.8);
}

.files-search-box input {
  width: 100%;
  padding: 12px 16px 12px 48px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 14px;
  font-size: 0.95rem;
  background: rgba(15, 23, 42, 0.85);
  color: #f8fafc;
  transition: all 0.2s;
}

.files-search-box input::placeholder {
  color: rgba(148, 163, 184, 0.7);
}

.files-search-box input:focus {
  outline: none;
  border-color: rgba(56, 189, 248, 0.6);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.files-sort {
  padding: 12px 16px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 14px;
  font-size: 0.9rem;
  background: rgba(15, 23, 42, 0.85);
  color: #f8fafc;
  cursor: pointer;
  transition: all 0.2s;
}

.files-sort:hover,
.files-sort:focus {
  border-color: rgba(56, 189, 248, 0.6);
}

.files-view-toggle {
  display: inline-flex;
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 999px;
  overflow: hidden;
}

.view-toggle-btn {
  border: none;
  background: transparent;
  color: rgba(226, 232, 240, 0.7);
  padding: 8px 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.view-toggle-btn.active {
  background: rgba(56, 189, 248, 0.18);
  color: #f8fafc;
}

.files-refresh-btn {
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: transparent;
  color: rgba(226, 232, 240, 0.85);
}

.files-refresh-btn:hover {
  border-color: rgba(56, 189, 248, 0.7);
  color: #f8fafc;
}

/* ===============================
   Files Grid
   =============================== */

.files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 22px;
}

.files-grid[data-view="list"] {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.file-card {
  position: relative;
  background: rgba(15, 23, 42, 0.88);
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.15);
  transition: all 0.3s;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  box-shadow: 0 18px 38px rgba(2, 6, 23, 0.5);
}

.file-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 28px 55px rgba(2, 6, 23, 0.6);
  border-color: rgba(56, 189, 248, 0.4);
}

.file-card-preview {
  aspect-ratio: 4/3;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.18), rgba(99, 102, 241, 0.18));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.file-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-icon-large {
  font-size: 3rem;
  opacity: 0.65;
  color: #e0f2fe;
}

.file-card-info {
  padding: 16px 18px 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.file-card-name {
  font-weight: 600;
  font-size: 1rem;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-card-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 0.85rem;
  color: rgba(148, 163, 184, 0.9);
}

.file-card-actions {
  display: flex;
  gap: 6px;
  padding: 10px 14px 16px;
}

.file-action-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(15, 23, 42, 0.75);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  color: rgba(148, 163, 184, 0.9);
}

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

.file-action-btn:hover {
  border-color: rgba(56, 189, 248, 0.7);
  color: #f8fafc;
}

.file-action-btn.file-action-delete:hover {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.8);
  color: #fecaca;
}

.file-favorite-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.25);
  color: rgba(248, 250, 252, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.file-favorite-btn.active {
  color: #fcd34d;
  border-color: #fcd34d;
  background: rgba(250, 204, 21, 0.15);
}

.files-grid[data-view="list"] .file-card {
  flex-direction: row;
  align-items: center;
  gap: 18px;
  padding: 12px 18px;
}

.files-grid[data-view="list"] .file-card-preview {
  width: 132px;
  min-width: 132px;
  border-radius: 14px;
}

.files-grid[data-view="list"] .file-card-info {
  flex: 1;
}

.files-grid[data-view="list"] .file-card-actions {
  flex-direction: row;
  justify-content: flex-end;
  width: 220px;
  padding: 0;
  border: none;
  gap: 8px;
}

.files-grid[data-view="list"] .file-action-btn {
  flex: 0 0 auto;
  width: 48px;
  height: 40px;
}

/* ===============================
   Empty State
   =============================== */

.files-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
  color: rgba(148, 163, 184, 0.9);
  background: rgba(15, 23, 42, 0.65);
  border-radius: 22px;
  border: 1px dashed rgba(148, 163, 184, 0.3);
}

.empty-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.files-empty-state h3 {
  margin: 0 0 8px;
  color: var(--fg);
  font-size: 1.2rem;
}

.files-empty-state p {
  margin: 0;
  font-size: 0.9rem;
}

/* ===============================
   Modal Styles
   =============================== */

.files-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.files-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.files-modal-content {
  position: relative;
  background: white;
  border-radius: 16px;
  max-width: 90vw;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.files-modal-small {
  max-width: 500px;
  max-height: auto;
}

.files-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.files-modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  flex: 1;
}

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

.modal-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 1.2rem;
  padding: 0;
}

.modal-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.modal-close {
  font-size: 1.5rem;
  font-weight: 300;
}

.files-modal-body {
  padding: 24px;
  overflow: auto;
  flex: 1;
}

/* Preview Content */

.preview-image {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 8px;
  display: block;
  margin: 0 auto;
}

.preview-pdf {
  height: 70vh;
}

.preview-iframe {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 8px;
}

.preview-video {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 8px;
  display: block;
  margin: 0 auto;
}

.preview-unsupported {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  text-align: center;
}

.preview-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.preview-unsupported h3 {
  margin: 0 0 8px;
  font-size: 1.1rem;
  color: var(--fg);
}

.preview-unsupported p {
  margin: 0 0 8px;
  color: var(--muted);
}

.preview-note {
  background: #fef3c7;
  color: #92400e;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 16px !important;
}

/* Rename Modal */

.files-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  font-size: 1rem;
  margin-bottom: 16px;
  transition: all 0.2s;
}

.files-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.modal-actions-row {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* ===============================
   Storage Widget
   =============================== */

.storage-widget {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 16px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 16px;
  min-width: 180px;
  box-shadow: 0 18px 40px rgba(2, 6, 23, 0.45);
}

.storage-bar {
  width: 100%;
  height: 6px;
  background: rgba(148, 163, 184, 0.25);
  border-radius: 999px;
  overflow: hidden;
}

.storage-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.storage-fill.storage-normal {
  background: linear-gradient(90deg, #10b981 0%, #059669 100%);
}

.storage-fill.storage-warning {
  background: linear-gradient(90deg, #f59e0b 0%, #d97706 100%);
}

.storage-fill.storage-critical {
  background: linear-gradient(90deg, #dc2626 0%, #b91c1c 100%);
}

.storage-text {
  font-size: 0.8rem;
  color: rgba(148, 163, 184, 0.9);
  font-weight: 500;
  text-align: center;
}

/* ===============================
   Responsive Design
   =============================== */

@media (max-width: 1200px) {
  .files-layout {
    grid-template-columns: 1fr;
  }

  .files-sidebar {
    position: static;
    top: auto;
  }

  .files-hero {
    flex-direction: column;
  }
}

@media (max-width: 968px) {
  .files-layout {
    grid-template-columns: 1fr;
  }

  .files-sidebar {
    position: static;
  }

  .files-categories {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .files-category-btn {
    flex: 1 1 calc(50% - 4px);
    min-width: 140px;
  }

  .files-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .files-toolbar-left,
  .files-toolbar-right {
    width: 100%;
    justify-content: space-between;
  }

  .files-search-box {
    width: 100%;
  }

  .files-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 18px;
  }
}

@media (max-width: 640px) {
  .files-search-box,
  .files-sort,
  .files-toolbar-left,
  .files-toolbar-right {
    width: 100%;
  }

  .files-toolbar-right {
    flex-direction: column;
    align-items: stretch;
  }

  .files-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
  }

  .files-modal-content {
    max-width: 95vw;
    max-height: 95vh;
  }

  .files-modal-header {
    padding: 16px;
  }

  .files-modal-body {
    padding: 16px;
  }

  .storage-widget {
    min-width: 100%;
  }

  .category-label {
    font-size: 0.85rem;
  }
}

/* ===============================
   Dark Mode Support
   =============================== */

@media (prefers-color-scheme: dark) {
  .files-modal-content {
    background: #0f172a;
    color: #e2e8f0;
  }

  .files-modal-body {
    color: #e2e8f0;
  }

  .files-input {
    background: rgba(15, 23, 42, 0.85);
    border-color: rgba(148, 163, 184, 0.3);
    color: #f8fafc;
  }

  .preview-unsupported h3 {
    color: #f8fafc;
  }
}

/* ===============================
   Print Styles
   =============================== */

@media print {
  .files-sidebar,
  .files-upload-section,
  .files-toolbar,
  .file-card-actions,
  .files-modal {
    display: none !important;
  }
}
