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

:root {
  --blue: #1a73e8;
  --blue-dark: #1557b0;
  --blue-light: #e8f0fe;
  --text: #202124;
  --text-secondary: #5f6368;
  --border: #dadce0;
  --bg: #f8f9fa;
  --white: #ffffff;
  --danger: #d93025;
  --success: #1e8e3e;
  --warning: #f29900;
  --shadow: 0 1px 3px rgba(60,64,67,.3), 0 4px 8px rgba(60,64,67,.15);
  --shadow-sm: 0 1px 2px rgba(60,64,67,.3);
  --radius: 8px;
  --radius-lg: 12px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ─── Auth Screen ───────────────────────────────────────────────────── */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a73e8 0%, #0d47a1 100%);
}

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

.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo .logo-icon {
  font-size: 48px;
  color: var(--blue);
  display: block;
  margin-bottom: 8px;
}

.auth-logo h1 {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.auth-tagline {
  color: var(--text-secondary);
  font-size: 13px;
}

.auth-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.auth-tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

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

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

.form-group input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  font-family: var(--font);
}

.form-group input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26,115,232,.12);
}

.form-error {
  background: #fce8e6;
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
}

/* ─── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
}

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

.btn-primary {
  background: var(--blue);
  color: var(--white);
  border-color: var(--blue);
}

.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }

.btn-block { width: 100%; justify-content: center; border-radius: var(--radius); }

.btn-sm { padding: 6px 12px; font-size: 12px; }

.btn-icon {
  padding: 8px;
  border-radius: 50%;
  border: none;
  background: transparent;
}

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

.btn-icon.active { background: var(--blue-light); color: var(--blue); }

/* ─── Top Bar ─────────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 60px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
}

.topbar-logo-icon { font-size: 28px; color: var(--blue); }

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.topbar-center { flex: 1; max-width: 600px; margin: 0 auto; }

.search-box {
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 0 16px;
  height: 40px;
  gap: 8px;
  transition: all 0.2s;
}

.search-box:focus-within {
  background: var(--white);
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26,115,232,.12);
}

.search-icon { color: var(--text-secondary); font-size: 20px; }

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

.topbar-right { display: flex; align-items: center; gap: 8px; position: relative; }

.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 20px;
  transition: background 0.2s;
  user-select: none;
}

.user-menu:hover { background: var(--bg); }

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--blue);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 200px;
  z-index: 200;
  overflow: hidden;
}

.dropdown-info {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dropdown-info strong { font-size: 14px; }
.dropdown-info small { color: var(--text-secondary); font-size: 12px; }

.user-dropdown hr { border: none; border-top: 1px solid var(--border); }

.user-dropdown button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  font-family: var(--font);
  transition: background 0.15s;
}

.user-dropdown button:hover { background: var(--bg); }

/* ─── Main Layout ─────────────────────────────────────────────────── */
.app { min-height: 100vh; }

.main-layout {
  display: flex;
  padding-top: 60px;
  min-height: 100vh;
}

/* ─── Sidebar ─────────────────────────────────────────────────────── */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--white);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: fixed;
  top: 60px;
  bottom: 0;
  overflow-y: auto;
}

.upload-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: var(--blue);
  color: var(--white);
  border: none;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
  box-shadow: 0 1px 3px rgba(26,115,232,.4);
  margin-bottom: 8px;
}

.upload-btn:hover {
  background: var(--blue-dark);
  box-shadow: 0 2px 6px rgba(26,115,232,.5);
  transform: translateY(-1px);
}

.upload-btn .material-icons { font-size: 20px; }
.upload-btn-folder {
  background: var(--white);
  color: var(--blue);
  border: 1.5px solid var(--blue);
  box-shadow: none;
}
.upload-btn-folder:hover {
  background: #e8f0fe;
  box-shadow: none;
  transform: translateY(-1px);
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 0 24px 24px 0;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  cursor: pointer;
}

.nav-item:hover { background: var(--bg); }
.nav-item.active { background: var(--blue-light); color: var(--blue); }
.nav-item .material-icons { font-size: 20px; color: var(--text-secondary); }
.nav-item.active .material-icons { color: var(--blue); }

.storage-info {
  padding: 12px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.storage-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

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

.storage-used {
  height: 100%;
  background: var(--blue);
  border-radius: 2px;
  transition: width 0.5s;
}

/* ─── Content Area ────────────────────────────────────────────────── */
.content {
  flex: 1;
  margin-left: 240px;
  padding: 20px 24px;
  min-height: calc(100vh - 60px);
  position: relative;
}

/* ─── Breadcrumb ──────────────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.breadcrumb-item {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: all 0.15s;
}

.breadcrumb-item:hover { background: var(--bg); color: var(--blue); }
.breadcrumb-item.active { color: var(--text); font-weight: 500; }
.breadcrumb-item .material-icons { font-size: 16px; }

.breadcrumb-sep { color: var(--text-secondary); font-size: 18px; }

/* ─── Toolbar ─────────────────────────────────────────────────────── */
.content-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.toolbar-right { display: flex; gap: 4px; }

/* ─── Drop Overlay ────────────────────────────────────────────────── */
.drop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(26,115,232,.08);
  border: 3px dashed var(--blue);
  border-radius: var(--radius-lg);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.drop-message {
  text-align: center;
  color: var(--blue);
}

.drop-message .material-icons { font-size: 64px; display: block; margin-bottom: 12px; }
.drop-message p { font-size: 18px; font-weight: 500; }

/* ─── File Table ──────────────────────────────────────────────────── */
.file-area { position: relative; min-height: 300px; }

.file-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.file-table thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.file-table tbody tr {
  transition: background 0.15s;
  cursor: pointer;
}

.file-table tbody tr:hover { background: #f1f3f4; }

.file-table tbody tr:not(:last-child) td { border-bottom: 1px solid #f1f3f4; }

.file-table td {
  padding: 10px 16px;
  vertical-align: middle;
}

.col-icon { width: 40px; }
.col-size { width: 100px; color: var(--text-secondary); }
.col-date { width: 150px; color: var(--text-secondary); }
.col-actions { width: 80px; }

.file-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-icon .material-icons { font-size: 24px; }
.icon-folder { color: #fbbc04; }
.icon-image { color: #34a853; }
.icon-video { color: #ea4335; }
.icon-audio { color: #9c27b0; }
.icon-pdf { color: #ea4335; }
.icon-doc { color: #1a73e8; }
.icon-zip { color: #ff6d00; }
.icon-code { color: #0f9d58; }
.icon-file { color: #9aa0a6; }

.file-name { font-weight: 500; color: var(--text); }

.row-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}

.file-table tbody tr:hover .row-actions { opacity: 1; }

.action-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s;
}

.action-btn:hover { background: var(--border); color: var(--text); }

.action-btn .material-icons { font-size: 18px; }

/* ─── Grid View ───────────────────────────────────────────────────── */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  padding: 4px;
}

.grid-item {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  text-align: center;
}

.grid-item:hover {
  background: #f1f3f4;
  box-shadow: var(--shadow-sm);
  border-color: transparent;
}

.grid-item .material-icons { font-size: 48px; }

.grid-item-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  word-break: break-word;
  max-width: 100%;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.grid-item-size { font-size: 11px; color: var(--text-secondary); }

.grid-item-menu {
  position: absolute;
  top: 6px;
  right: 6px;
  opacity: 0;
  transition: opacity 0.15s;
}

.grid-item:hover .grid-item-menu { opacity: 1; }

/* ─── Empty & Loading States ──────────────────────────────────────── */
.empty-state, .loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  color: var(--text-secondary);
  gap: 12px;
}

.empty-state .material-icons, .loading-state .material-icons {
  font-size: 64px;
  opacity: 0.4;
}

.empty-state p, .loading-state p { font-size: 16px; font-weight: 500; }
.empty-state small { font-size: 13px; opacity: 0.7; }

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ─── Context Menu ────────────────────────────────────────────────── */
.context-menu {
  position: fixed;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 1000;
  overflow: hidden;
  min-width: 180px;
  max-width: calc(100vw - 16px);
}

.context-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text);
  transition: background 0.15s;
}

.context-menu button:hover { background: var(--bg); }
.context-menu button.danger { color: var(--danger); }
.context-menu button.danger:hover { background: #fce8e6; }
.context-menu hr { border: none; border-top: 1px solid var(--border); }

/* ─── Modal ───────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 420px;
  overflow: hidden;
}

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

.modal-header h3 { font-size: 16px; font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px;
  border-radius: 50%;
  display: flex;
}

.modal-close:hover { background: var(--bg); }

.modal-body { padding: 20px; }

.modal-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
}

.modal-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26,115,232,.12);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

/* ─── Folder Picker ───────────────────────────────────────────────── */
.folder-picker {
  max-height: 300px;
  overflow-y: auto;
}

.folder-picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
  font-size: 14px;
}

.folder-picker-item:hover { background: var(--bg); }
.folder-picker-item.selected { background: var(--blue-light); color: var(--blue); }
.folder-picker-item .material-icons { color: #fbbc04; }

/* ─── Upload Panel ────────────────────────────────────────────────── */
.upload-panel {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 360px;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  z-index: 500;
  overflow: hidden;
}

.upload-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #333;
  color: white;
  font-weight: 500;
  font-size: 14px;
}

.upload-panel-header .material-icons { font-size: 20px; }

.panel-toggle {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: white;
  display: flex;
}

.upload-list {
  max-height: 280px;
  overflow-y: auto;
  transition: max-height 0.2s ease;
}

.upload-list.collapsed {
  max-height: 0;
  overflow: hidden;
}

.upload-item {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.upload-item-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.upload-item-name {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}

.upload-item-status {
  font-size: 12px;
  color: var(--text-secondary);
}

.upload-item-status.success { color: var(--success); }
.upload-item-status.error { color: var(--danger); }

.upload-progress {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.upload-progress-bar {
  height: 100%;
  background: var(--blue);
  border-radius: 2px;
  transition: width 0.3s;
}

/* ─── Toast ───────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  background: #333;
  color: white;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 14px;
  box-shadow: var(--shadow);
  animation: slideUp 0.3s ease;
  white-space: nowrap;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); color: #333; }

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

/* ─── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    width: 60px;
    overflow: visible;
  }

  .sidebar .upload-btn span:not(.material-icons),
  .sidebar .nav-item span:not(.material-icons),
  .sidebar .storage-info .storage-label,
  .topbar-title {
    display: none;
  }

  .nav-item { justify-content: center; padding: 10px; border-radius: 50%; }
  .upload-btn { padding: 12px; border-radius: 50%; justify-content: center; }
  .content { margin-left: 60px; padding: 12px; }

  .col-size, .col-date { display: none; }

  .upload-panel {
    width: calc(100vw - 40px);
    right: 20px;
  }

  .auth-card { margin: 20px; }
}
