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

:root {
  --primary: #6366f1;
  --primary-light: #818cf8;
  --primary-dark: #4f46e5;
  --primary-bg: rgba(99, 102, 241, 0.08);
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #22c55e;
  --warning: #f59e0b;
  --bg: #f0f2f5;
  --surface: #ffffff;
  --surface-hover: #f8f9fc;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow: 0 4px 20px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
    'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ========== Header ========== */
.header {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 28px;
  line-height: 1;
}

.logo-text {
  font-size: 20px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  line-height: 1;
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.45);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: var(--danger-hover);
}

.btn-sm {
  padding: 7px 14px;
  font-size: 13px;
}

/* ========== App Layout ========== */
.app-container {
  display: flex;
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 24px;
  gap: 24px;
  min-height: calc(100vh - 64px);
}

/* ========== Sidebar ========== */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  position: sticky;
  top: 84px;
  align-self: flex-start;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.storage-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 500;
}

.storage-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.storage-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 3px;
  transition: width 0.5s ease;
  width: 0%;
}

.storage-text {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-size: 14px;
  color: var(--text-secondary);
  position: relative;
}

.nav-item:hover {
  background: var(--primary-bg);
  color: var(--primary);
}

.nav-item.active {
  background: var(--primary-bg);
  color: var(--primary);
  font-weight: 600;
}

.nav-icon {
  font-size: 16px;
  line-height: 1;
}

.nav-label {
  flex: 1;
}

.nav-count {
  font-size: 12px;
  background: var(--border);
  padding: 2px 8px;
  border-radius: 10px;
  color: var(--text-muted);
  font-weight: 500;
  min-width: 24px;
  text-align: center;
}

.nav-item.active .nav-count {
  background: var(--primary);
  color: #fff;
}

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

/* ========== Main Content ========== */
.main-content {
  flex: 1;
  min-width: 0;
}

/* ========== Search Bar ========== */
.search-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  transition: var(--transition);
}

.search-bar:focus-within {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.search-icon {
  font-size: 16px;
  line-height: 1;
  color: var(--text-muted);
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  background: transparent;
  color: var(--text);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.view-options {
  display: flex;
  gap: 4px;
  border-left: 1px solid var(--border);
  padding-left: 12px;
}

.view-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.view-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.view-btn.active {
  background: var(--primary-bg);
  color: var(--primary);
}

/* ========== Drop Zone ========== */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 50px 20px;
  text-align: center;
  margin-bottom: 20px;
  transition: var(--transition);
  cursor: pointer;
  background: var(--surface);
}

.drop-zone:hover {
  border-color: var(--primary-light);
  background: var(--primary-bg);
}

.drop-zone.dragover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.06);
  transform: scale(1.01);
}

.drop-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 12px;
}

.drop-zone-content p {
  color: var(--text-secondary);
  font-size: 15px;
}

.drop-hint {
  font-size: 13px !important;
  color: var(--text-muted) !important;
  margin-top: 4px;
}

/* ========== Category Tabs ========== */
.category-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.tab {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  font-weight: 500;
}

.tab:hover {
  border-color: var(--primary-light);
  color: var(--primary);
}

.tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ========== Files Header ========== */
.files-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}

.files-title {
  font-size: 18px;
  font-weight: 700;
}

.files-count {
  font-size: 13px;
  color: var(--text-muted);
}

/* ========== File Grid ========== */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.file-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px 16px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.file-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: var(--primary-light);
}

.file-card .file-icon {
  font-size: 40px;
  display: block;
  margin-bottom: 10px;
  line-height: 1;
}

.file-card .file-name {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 4px;
}

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

.file-card .card-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  opacity: 0;
  transition: var(--transition);
}

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

.file-card .card-delete {
  width: 28px;
  height: 28px;
  border: none;
  background: rgba(239, 68, 68, 0.1);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--danger);
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-card .card-delete:hover {
  background: var(--danger);
  color: #fff;
}

/* ========== File List ========== */
.file-list {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

.list-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
  gap: 12px;
}

.list-item:last-child {
  border-bottom: none;
}

.list-item:hover {
  background: var(--surface-hover);
}

.list-icon {
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
}

.list-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-size {
  font-size: 12px;
  color: var(--text-muted);
  width: 80px;
  text-align: right;
  flex-shrink: 0;
}

.list-date {
  font-size: 12px;
  color: var(--text-muted);
  width: 150px;
  text-align: right;
  flex-shrink: 0;
}

.list-type {
  font-size: 12px;
  color: var(--text-muted);
  width: 80px;
  text-align: right;
  flex-shrink: 0;
}

.list-delete {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-muted);
  transition: var(--transition);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.list-delete:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

/* ========== Empty State ========== */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 64px;
  display: block;
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
}

/* ========== Modal ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

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

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  animation: modalIn 0.25s ease;
}

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

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 22px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.modal-body {
  padding: 20px 24px;
  max-height: 60vh;
  overflow-y: auto;
}

.modal-body .preview-icon {
  font-size: 64px;
  display: block;
  text-align: center;
  margin-bottom: 16px;
}

.modal-body .preview-info {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.modal-body .preview-info-item {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 14px;
}

.modal-body .preview-info-item .label {
  color: var(--text-muted);
}

.modal-body .preview-info-item .value {
  font-weight: 500;
}

.modal-body .preview-image {
  max-width: 100%;
  max-height: 300px;
  border-radius: var(--radius-sm);
  display: block;
  margin: 0 auto 16px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 24px 20px;
}

/* ========== Toast Notification ========== */
.toast-container {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--primary);
  animation: slideInRight 0.3s ease;
  font-size: 14px;
  font-weight: 500;
  min-width: 200px;
  max-width: 360px;
}

.toast.success {
  border-left-color: var(--success);
}

.toast.error {
  border-left-color: var(--danger);
}

.toast.warning {
  border-left-color: var(--warning);
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideOutRight {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(40px);
  }
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
    padding: 12px 16px;
  }

  .sidebar {
    width: 100%;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px;
  }

  .sidebar .storage-info {
    width: 100%;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
  }

  .nav-item {
    padding: 6px 10px;
    font-size: 13px;
  }

  .nav-count {
    display: none;
  }

  .sidebar-footer {
    display: none;
  }

  .file-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
  }

  .header-inner {
    padding: 0 16px;
  }

  .drop-zone {
    padding: 30px 16px;
  }

  .list-date, .list-type {
    display: none;
  }

  .list-size {
    width: auto;
  }
}

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

  .file-card {
    padding: 14px 10px 12px;
  }

  .file-card .file-icon {
    font-size: 32px;
  }
}
