/* ═══════════════════════════════════════════════
   DESIGN TOKENS — Pastel palette inspired by Claude
   ═══════════════════════════════════════════════ */
:root {
  /* Background tones */
  --bg-base:        #F5F4F2;
  --bg-card:        #FFFFFF;
  --bg-sidebar:     #EFEDE8;
  --bg-hover:       #E8E5DE;

  /* Claude-inspired pastel accents */
  --brand-warm:     #DA7756;     /* terracotta / Claude orange-red */
  --brand-warm-lt:  #F0C4B4;     /* very light version */
  --brand-cool:     #8B7EC8;     /* soft lavender */
  --brand-cool-lt:  #DDD9F5;
  --brand-sage:     #7BA799;     /* muted sage green */
  --brand-sage-lt:  #D3EDEA;
  --brand-peach:    #E8A87C;
  --brand-peach-lt: #FAEBD7;

  /* Text hierarchy */
  --text-primary:   #1A1915;
  --text-secondary: #5C5750;
  --text-muted:     #9B948A;
  --text-inverse:   #FFFFFF;

  /* Borders */
  --border:         #E2DDD7;
  --border-strong:  #C8C2BA;

  /* Semantic / feedback */
  --error-bg:       #FEF2F0;
  --error-border:   #F5C6BC;
  --error-text:     #C0392B;

  /* Shadows */
  --shadow-xs:  0 1px 3px rgba(26,25,21,0.07);
  --shadow-sm:  0 2px 8px rgba(26,25,21,0.08);
  --shadow-md:  0 4px 20px rgba(26,25,21,0.10);
  --shadow-lg:  0 8px 40px rgba(26,25,21,0.12);

  /* Radii */
  --r-sm:  8px;
  --r-md:  12px;
  --r-lg:  16px;
  --r-xl:  24px;
  --r-full: 9999px;

  /* Sidebar */
  --sidebar-w: 240px;
}

/* ═══════════════ RESET & BASE ═══════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; }

body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }
.hidden { display: none !important; }
.screen.hidden { display: none !important; }

/* ═══════════════ LOGIN SCREEN ═══════════════ */
.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  position: relative;
  overflow: hidden;
  background: linear-gradient(145deg, #F7F4EF 0%, #EDE9E2 50%, #F2EEE8 100%);
}

.login-glow {
  position: absolute;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(218,119,86,0.12) 0%, transparent 70%);
  top: -100px;
  right: -100px;
  pointer-events: none;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  position: relative;
  z-index: 1;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-brand-logo {
  max-width: 200px;
  height: auto;
  margin-bottom: 20px;
  /* The logo has a white background, so we give it a clean container */
  background: white;
  padding: 10px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
}

.login-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 300px;
  margin: 0 auto;
}

.google-btn-holder {
  display: flex;
  justify-content: center;
  width: 100%;
}

.error-banner {
  width: 100%;
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: var(--r-sm);
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error-text);
  font-size: 13px;
  text-align: center;
}

.login-footer {
  margin-top: 24px;
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.3px;
  position: relative;
  z-index: 1;
}

/* ═══════════════ DASHBOARD SHELL ═══════════════ */
.dashboard-shell {
  display: flex;
  min-height: 100vh;
}

/* ═══════════════ SIDEBAR ═══════════════ */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.sidebar-brand-logo {
  max-width: 180px;
  width: 100%;
  height: auto;
  background: white;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  display: block;
  margin: 0 auto;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background 0.15s ease, color 0.15s ease;
  width: 100%;
  text-align: left;
}

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

.nav-item.active {
  background: var(--brand-warm-lt);
  color: var(--brand-warm);
}

.nav-icon { font-size: 16px; flex-shrink: 0; }
.nav-label { flex: 1; }

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

.user-avatar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--r-md);
  transition: background 0.15s;
}

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

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-warm) 0%, var(--brand-cool) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
}

.user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logout-btn {
  font-size: 11px;
  color: var(--text-muted);
  text-align: left;
  transition: color 0.15s;
  padding: 0;
}

.logout-btn:hover { color: var(--brand-warm); }

/* ═══════════════ CONTENT AREA ═══════════════ */
.content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-y: auto;
}

/* ═══════════════ BROWSER TOP BAR ═══════════════ */
.browser-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 0 16px 0;
}

.search-and-sort {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  align-items: center;
}

.search-bar {
  flex: 1;
}

.search-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 14px;
  font-family: inherit;
  background: var(--bg-card);
  color: var(--text-primary);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input:focus {
  outline: none;
  border-color: var(--brand-warm);
  box-shadow: 0 0 0 3px var(--brand-warm-lt);
}

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

.sort-bar {
  flex-shrink: 0;
}

.sort-select {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 14px;
  font-family: inherit;
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.sort-select:focus {
  outline: none;
  border-color: var(--brand-warm);
  box-shadow: 0 0 0 3px var(--brand-warm-lt);
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--r-full);
  background: var(--bg-base);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.back-btn:hover {
  background: var(--bg-card);
  border-color: var(--border-strong);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}

.back-arrow { font-size: 16px; }

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--r-full);
  background: var(--bg-base);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.header-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-warm) 0%, var(--brand-cool) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ═══════════════ BREADCRUMB ═══════════════ */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
}

.breadcrumb .crumb {
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--r-sm);
  transition: color 0.15s, background 0.15s;
  font-weight: 500;
}

.breadcrumb .crumb:hover { color: var(--brand-warm); background: var(--brand-warm-lt); }
.breadcrumb .crumb:last-child { color: var(--text-primary); cursor: default; background: none; }
.breadcrumb .crumb:last-child:hover { background: none; color: var(--text-primary); }

.breadcrumb .sep { color: var(--text-muted); margin: 0 2px; }

/* ═══════════════ FOLDERS SCREEN ═══════════════ */
.screen { padding: 32px; }

.page-intro { margin-bottom: 28px; }

.page-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
}

/* Folder cards grid */
.folders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

/* Pastel color cycling for folder cards */
.folder-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px 20px;
  cursor: pointer;
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
  width: 100%;
}

.folder-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--card-accent, var(--brand-warm));
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  opacity: 0;
  transition: opacity 0.2s;
}

.folder-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--border-strong);
}

.folder-card:hover::before { opacity: 1; }

.folder-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--r-md);
  background: var(--card-icon-bg, var(--brand-warm-lt));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.folder-card-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.folder-card-count {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.folder-card-arrow {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: auto;
  transition: transform 0.2s;
}

.folder-card:hover .folder-card-arrow { transform: translateX(4px); color: var(--brand-warm); }

/* Pastel accent variants */
.folder-card.accent-0 { --card-accent: #DA7756; --card-icon-bg: #F0C4B4; }
.folder-card.accent-1 { --card-accent: #8B7EC8; --card-icon-bg: #DDD9F5; }
.folder-card.accent-2 { --card-accent: #7BA799; --card-icon-bg: #D3EDEA; }
.folder-card.accent-3 { --card-accent: #C8A265; --card-icon-bg: #F5E9D4; }
.folder-card.accent-4 { --card-accent: #B06084; --card-icon-bg: #F2D4E2; }

/* ═══════════════ FILE LIST ═══════════════ */
.file-list {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.file-list-header {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-base);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
}

.file-row {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  transition: background 0.13s ease;
  cursor: pointer;
}

.file-row:last-child { border-bottom: none; }
.file-row:hover { background: var(--bg-base); }

.file-row.is-folder:hover .file-name { color: var(--brand-warm); }

.file-icon-wrap {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  background: var(--bg-base);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  margin-right: 14px;
  transition: background 0.13s;
}

.file-row.is-folder .file-icon-wrap { background: var(--brand-warm-lt); border-color: transparent; }
.file-row:hover.is-folder .file-icon-wrap { background: var(--brand-warm); }

.file-details { flex: 1; min-width: 0; }

.file-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.13s;
  display: block;
}

.file-date {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  display: block;
}

.file-path {
  font-size: 11px;
  color: var(--brand-cool);
  margin-top: 2px;
  display: block;
  font-style: italic;
}

.file-size {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-left: 16px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: var(--r-full);
  font-weight: 500;
}

.file-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: 12px;
}

.file-action-btn {
  flex-shrink: 0;
  padding: 6px 12px;
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 600;
  background: var(--brand-warm-lt);
  color: var(--brand-warm);
  border: 1px solid transparent;
  transition: background 0.15s, box-shadow 0.15s;
  opacity: 0;
  pointer-events: none;
}

.file-size {
  opacity: 1;
  pointer-events: auto;
}

.file-row:hover .file-action-btn {
  opacity: 1;
  pointer-events: auto;
}

.file-action-btn:hover {
  background: var(--brand-warm);
  color: white;
  box-shadow: var(--shadow-xs);
}

/* ═══════════════ EMPTY / LOADING STATES ═══════════════ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 32px;
  color: var(--text-muted);
  text-align: center;
  gap: 12px;
}

.empty-state-icon { font-size: 40px; opacity: 0.5; }
.empty-state-text { font-size: 14px; font-weight: 500; }
.empty-state-sub  { font-size: 13px; }

/* Loading spinner */
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--brand-warm);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ═══════════════ SCROLLBAR STYLING ═══════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ═══════════════ RESPONSIVE ═══════════════ */
@media (max-width: 640px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .content-area { width: 100%; }
  .screen { padding: 20px 16px; }
  .content-header { padding: 12px 16px; }
  .folders-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .folder-card { padding: 18px 14px; }
}

/* ═══════════════ PREVIEW MODAL ═══════════════ */
.preview-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.preview-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(26, 25, 21, 0.7);
  backdrop-filter: blur(4px);
}

.preview-content {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.preview-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  margin-right: 12px;
}

.preview-close {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  background: var(--bg-base);
  border: 1px solid var(--border);
  font-size: 16px;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.preview-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.preview-body {
  flex: 1;
  position: relative;
  background: var(--bg-base);
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.preview-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 14px;
}

.preview-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: white;
}

.preview-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: white;
}

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

.preview-download-btn {
  padding: 8px 16px;
  border-radius: var(--r-sm);
  background: var(--brand-warm);
  color: white;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s, box-shadow 0.15s;
}

.preview-download-btn:hover {
  background: var(--brand-warm-lt);
  color: var(--brand-warm);
  box-shadow: var(--shadow-xs);
}
