/* FileShare - Custom styles + Tailwind imports */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ===== BASE ===== */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg-base: #0f1117;
  --bg-surface: #181c27;
  --bg-elevated: #1e2235;
  --bg-hover: #252a3d;
  --border: rgba(255,255,255,0.07);
  --border-focus: rgba(99,102,241,0.6);
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-dim: rgba(99,102,241,0.15);
  --text-primary: #e8eaf0;
  --text-secondary: #8b90a8;
  --text-muted: #525870;
  --success: #34d399;
  --danger: #f87171;
  --warning: #fbbf24;
  --info: #60a5fa;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.25);
  --transition: 0.18s ease;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== LAYOUT ===== */
.app-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 100vh;
  overflow: hidden;
}

.sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  gap: 8px;
  overflow-y: auto;
}

.main-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== TOPBAR ===== */
.topbar {
  height: 60px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
}

/* ===== LOGO ===== */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  padding: 8px 0;
  letter-spacing: -0.3px;
}
.logo-icon {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}

/* ===== PROFILE CARD ===== */
.profile-card {
  position: relative;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.profile-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
  width: 100%;
}
.profile-trigger:hover { background: var(--bg-elevated); }

.profile-avatar {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: white;
  flex-shrink: 0;
}

.profile-info { flex: 1; min-width: 0; }
.profile-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-storage-text {
  font-size: 11px;
  color: var(--text-secondary);
}

.profile-popup {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow);
  z-index: 100;
}

/* ===== STORAGE BAR ===== */
.storage-bar-container {
  margin: 10px 0;
}
.storage-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.storage-bar-track {
  height: 5px;
  background: var(--bg-hover);
  border-radius: 99px;
  overflow: hidden;
}
.storage-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.5s ease;
}
.storage-bar-fill.warn { background: var(--warning); }
.storage-bar-fill.danger { background: var(--danger); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.12);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(248,113,113,0.2);
}
.btn-danger:hover {
  background: rgba(248,113,113,0.1);
}

.btn-icon {
  padding: 7px;
  border-radius: 8px;
}

/* ===== FORMS ===== */
.input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}
.input::placeholder { color: var(--text-muted); }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

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

.form-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: 4px;
}

/* ===== AUTH PAGE ===== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow);
}

/* ===== TABS ===== */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 3px;
  margin-bottom: 28px;
}
.tab-btn {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: transparent;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.tab-btn.active {
  background: var(--accent);
  color: white;
}
.tab-btn:hover:not(.active) { color: var(--text-primary); }

/* ===== FILE AREA ===== */
.file-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ===== DROP ZONE ===== */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  transition: all var(--transition);
  cursor: pointer;
  margin-bottom: 24px;
  background: transparent;
}
.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.drop-zone-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.6; }
.drop-zone-text { font-size: 14px; color: var(--text-secondary); }
.drop-zone-text strong { color: var(--text-primary); }

/* ===== UPLOAD PROGRESS ===== */
.upload-progress-list {
  margin-bottom: 20px;
}
.upload-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 8px;
}
.upload-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.upload-item-name {
  font-size: 13px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 300px;
}
.upload-item-size {
  font-size: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.progress-track {
  height: 4px;
  background: var(--bg-hover);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.3s ease;
}
.progress-fill.complete { background: var(--success); }
.progress-fill.error { background: var(--danger); }

/* ===== FILE TABLE ===== */
.file-table {
  width: 100%;
  border-collapse: collapse;
}
.file-table th {
  padding: 8px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
  cursor: pointer;
}
.file-table th:hover { color: var(--text-secondary); }
.file-table th.active { color: var(--accent); }

.file-row {
  transition: background var(--transition);
  cursor: pointer;
  user-select: none;
  border-radius: var(--radius);
}
.file-row:hover { background: var(--bg-elevated); }
.file-row.selected { background: var(--accent-dim); }
.file-row.drag-source { opacity: 0.4; }
.file-row.drag-over-target { background: var(--accent-dim); outline: 1px solid var(--accent); }

.file-row td {
  padding: 10px 12px;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.file-row td:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.file-row td:last-child { border-radius: 0 var(--radius) var(--radius) 0; }

/* File name with overflow fade */
.file-name-cell {
  max-width: 280px;
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
}

.file-name-text {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: clip;
  position: relative;
  flex: 1;
  min-width: 0;
}
.file-name-text::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 40px; height: 100%;
  background: linear-gradient(to right, transparent, var(--bg-base));
  pointer-events: none;
  transition: opacity var(--transition);
}
.file-row:hover .file-name-text::after { opacity: 0; }

/* File type icon */
.file-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  background: var(--bg-hover);
}
.file-icon.type-image { background: rgba(52,211,153,0.12); color: var(--success); }
.file-icon.type-video { background: rgba(96,165,250,0.12); color: var(--info); }
.file-icon.type-audio { background: rgba(251,191,36,0.12); color: var(--warning); }
.file-icon.type-archive { background: rgba(248,113,113,0.12); color: var(--danger); }
.file-icon.type-folder { background: rgba(99,102,241,0.12); color: var(--accent); }
.file-icon.type-file { background: var(--bg-hover); color: var(--text-secondary); }

/* ===== TILE VIEW ===== */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.file-tile {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  user-select: none;
}
.file-tile:hover {
  background: var(--bg-elevated);
  border-color: rgba(255,255,255,0.12);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.file-tile.selected { border-color: var(--accent); background: var(--accent-dim); }
.file-tile.drag-source { opacity: 0.4; }

.file-tile-icon {
  font-size: 36px;
  margin-bottom: 10px;
  display: block;
}
.file-tile-name {
  font-size: 12px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.file-tile-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Public badge */
.public-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 16px;
  height: 16px;
  background: var(--success);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
}

/* ===== CONTEXT MENU ===== */
.context-menu {
  position: fixed;
  z-index: 9999;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 6px;
  min-width: 180px;
  box-shadow: var(--shadow);
  animation: ctxIn 0.1s ease;
}
@keyframes ctxIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
.ctx-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--transition);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}
.ctx-item:hover { background: var(--bg-hover); }
.ctx-item.danger { color: var(--danger); }
.ctx-item.danger:hover { background: rgba(248,113,113,0.1); }
.ctx-item.success { color: var(--success); }
.ctx-separator {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-title { font-size: 17px; font-weight: 600; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 20px;
  padding: 4px;
  line-height: 1;
  border-radius: 6px;
  transition: all var(--transition);
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

/* Media viewer */
.media-viewer {
  max-width: 90vw;
  max-height: 90vh;
}
.media-viewer img, .media-viewer video {
  max-width: 100%;
  max-height: 80vh;
  border-radius: var(--radius);
}

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
  animation: toastIn 0.3s ease;
  max-width: 320px;
  pointer-events: all;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--info); }

/* ===== BREADCRUMBS ===== */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  flex-wrap: wrap;
}
.breadcrumb-item {
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--transition);
  text-decoration: none;
}
.breadcrumb-item:hover { color: var(--accent); }
.breadcrumb-item.active { color: var(--text-primary); cursor: default; }
.breadcrumb-sep { color: var(--text-muted); }

/* ===== SELECTION BOX ===== */
.selection-box {
  position: fixed;
  border: 1px solid var(--accent);
  background: var(--accent-dim);
  pointer-events: none;
  z-index: 500;
  border-radius: 3px;
}

/* ===== ARCHIVE VIEWER ===== */
.archive-table {
  width: 100%;
  font-size: 13px;
}
.archive-table th {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.archive-table td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

/* ===== VIEW TOGGLE ===== */
.view-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 3px;
}
.view-btn {
  padding: 6px 10px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 14px;
}
.view-btn.active {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 80px 24px;
  color: var(--text-secondary);
}
.empty-state-icon { font-size: 56px; margin-bottom: 16px; opacity: 0.4; }
.empty-state-title { font-size: 18px; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; }
.empty-state-sub { font-size: 14px; }

/* ===== SIDEBAR NAV ===== */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  border: none;
  background: transparent;
  width: 100%;
}
.nav-item:hover { background: var(--bg-elevated); color: var(--text-primary); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); }

/* ===== SORT INDICATOR ===== */
.sort-icon { font-size: 10px; margin-left: 4px; }

/* ===== CHECKBOX ===== */
.file-checkbox {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ===== RESPONSIVE MOBILE ===== */
@media (max-width: 768px) {
  .app-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .sidebar {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    width: 100%;
    padding-top: 60px;
  }
  .sidebar.mobile-open { display: flex; }
  .topbar { padding: 0 16px; }
  .file-area { padding: 12px; }
  .drop-zone { padding: 24px; }
  .file-table th:nth-child(3),
  .file-table td:nth-child(3),
  .file-table th:nth-child(4),
  .file-table td:nth-child(4) { display: none; }
  .auth-card { padding: 24px; }
  .upload-item-name { max-width: 160px; }
  .file-name-cell { max-width: 160px; }
  .modal { padding: 20px; }
  .toast-container { bottom: 16px; right: 16px; left: 16px; }
}

/* ===== ANIMATIONS ===== */
.fade-in { animation: fadeIn 0.2s ease; }
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.slide-up { animation: slideUp 0.25s ease; }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== FOLDER HIGHLIGHT (DnD target) ===== */
.folder-drop-target {
  outline: 2px solid var(--accent);
  background: var(--accent-dim);
}

/* Change password form */
.change-pwd-form { margin-top: 12px; }