/* ══════════════════════════════════════════
   Family Document Manager — Styles
   Sharp edges, flat colors, fully responsive
   ══════════════════════════════════════════ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --sidebar-width: 280px;
  --sidebar-bg: #0f1117;
  --sidebar-hover: #1a1d28;
  --sidebar-active: #252836;
  --sidebar-text: #8b8fa3;
  --sidebar-text-active: #ffffff;
  --sidebar-accent: #3b82f6;
  --bg-primary: #f5f6f8;
  --bg-card: #ffffff;
  --bg-hover: #f0f1f4;
  --text-primary: #111318;
  --text-secondary: #5f6377;
  --text-muted: #9198a8;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #eff4ff;
  --danger: #dc2626;
  --success: #16a34a;
  --border: #e2e4ea;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --transition: 0.2s ease;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── LOGIN SCREEN ── */
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--sidebar-bg);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-overlay.hidden { display: none; }
.login-container {
  text-align: center;
  padding: 48px 40px;
  background: #181b25;
  border: 1px solid rgba(255,255,255,0.06);
  width: 100%;
  max-width: 380px;
  margin: 20px;
}
.login-icon { color: var(--sidebar-accent); margin-bottom: 20px; }
.login-container h1 {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
}
.login-container p {
  font-size: 13px;
  color: var(--sidebar-text);
  margin-bottom: 28px;
}
.pin-inputs {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 20px;
}
.pin-box {
  width: 52px;
  height: 60px;
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  font-family: var(--font);
  background: #0f1117;
  border: 2px solid rgba(255,255,255,0.1);
  color: #fff;
  outline: none;
  transition: border-color var(--transition);
  caret-color: var(--sidebar-accent);
}
.pin-box:focus { border-color: var(--sidebar-accent); }
.pin-box.error { border-color: var(--danger); animation: shake 0.4s; }
.login-error {
  font-size: 12px;
  color: var(--danger);
  min-height: 20px;
  margin-bottom: 12px;
}
.login-btn {
  width: 100%;
  padding: 12px;
  background: var(--sidebar-accent);
  color: #fff;
  border: none;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}
.login-btn:hover { background: var(--accent-hover); }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}
.sidebar-header {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.logo-icon {
  width: 42px; height: 42px;
  background: var(--sidebar-accent);
  display: flex; align-items: center; justify-content: center;
  color: #fff; flex-shrink: 0;
}
.logo-text h1 { font-size: 15px; font-weight: 700; color: #fff; letter-spacing: -0.3px; }
.logo-text span { font-size: 11px; color: var(--sidebar-text); font-weight: 400; letter-spacing: 0.5px; text-transform: uppercase; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); }
.nav-section-label {
  font-size: 10px; font-weight: 600; color: var(--sidebar-text);
  text-transform: uppercase; letter-spacing: 1.2px; padding: 16px 20px 8px;
}
.nav-member-btn {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 11px 20px; border: none; background: none;
  color: var(--sidebar-text); font-family: var(--font);
  font-size: 13.5px; font-weight: 500; cursor: pointer;
  transition: all var(--transition); text-align: left;
}
.nav-member-btn:hover { background: var(--sidebar-hover); color: var(--sidebar-text-active); }
.nav-member-btn.active {
  background: var(--sidebar-active); color: var(--sidebar-text-active);
  border-left: 3px solid var(--sidebar-accent); padding-left: 17px;
}
.nav-member-btn .nav-icon {
  width: 32px; height: 32px; display: flex; align-items: center;
  justify-content: center; font-size: 15px; flex-shrink: 0; background: rgba(255,255,255,0.06);
}
.nav-member-btn .nav-count {
  margin-left: auto; font-size: 11px; color: var(--sidebar-text);
  background: rgba(255,255,255,0.06); padding: 2px 8px; font-weight: 600;
}
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex; flex-direction: column; gap: 10px;
}
.doc-count { font-size: 11px; color: var(--sidebar-text); text-align: center; }
.logout-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08);
  color: var(--sidebar-text); font-family: var(--font); font-size: 12px;
  cursor: pointer; transition: all var(--transition);
}
.logout-btn:hover { background: rgba(220,38,38,0.15); color: #f87171; border-color: rgba(220,38,38,0.3); }

/* ── Mobile Header ── */
.mobile-header {
  display: none; position: fixed; top: 0; left: 0; right: 0;
  height: 56px; background: var(--sidebar-bg); color: #fff;
  align-items: center; padding: 0 16px; z-index: 90; gap: 12px;
}
.mobile-header h1 { font-size: 16px; font-weight: 600; flex: 1; }
.hamburger {
  width: 36px; height: 36px; background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 5px;
}
.hamburger span { display: block; width: 20px; height: 2px; background: #fff; transition: all 0.3s; }
.mobile-search-toggle { color: #fff; cursor: pointer; display: flex; align-items: center; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 95; }

/* ── Main Content ── */
.main-content { margin-left: var(--sidebar-width); flex: 1; min-height: 100vh; display: flex; flex-direction: column; }

/* ── Topbar ── */
.topbar {
  position: sticky; top: 0; background: var(--bg-card); border-bottom: 1px solid var(--border);
  padding: 16px 32px; display: flex; align-items: center; gap: 20px; z-index: 50;
}
.search-box { flex: 1; max-width: 560px; position: relative; display: flex; align-items: center; }
.search-icon { position: absolute; left: 14px; color: var(--text-muted); pointer-events: none; }
.search-box input {
  width: 100%; padding: 10px 36px 10px 42px; border: 2px solid var(--border);
  background: var(--bg-primary); font-family: var(--font); font-size: 13.5px;
  color: var(--text-primary); outline: none; transition: border-color var(--transition);
}
.search-box input:focus { border-color: var(--accent); }
.search-box input::placeholder { color: var(--text-muted); }
.search-clear {
  position: absolute; right: 10px; background: none; border: none;
  font-size: 18px; color: var(--text-muted); cursor: pointer; display: none; padding: 4px;
}
.search-clear.visible { display: block; }
.topbar-stats { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* ── Content Area ── */
.content-area { flex: 1; padding: 32px; }

/* ── Welcome Screen ── */
.welcome-screen { text-align: center; padding: 60px 20px; }
.welcome-icon { color: var(--text-muted); margin-bottom: 20px; }
.welcome-screen h2 { font-size: 24px; font-weight: 700; margin-bottom: 8px; }
.welcome-screen p { font-size: 14px; color: var(--text-secondary); margin-bottom: 40px; }
.member-cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px; max-width: 800px; margin: 0 auto;
}
.member-card {
  background: var(--bg-card); border: 2px solid var(--border);
  padding: 28px 24px; cursor: pointer; transition: all var(--transition); text-align: left;
}
.member-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.member-card-icon {
  width: 48px; height: 48px; background: var(--accent-light); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 22px; margin-bottom: 16px;
}
.member-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.member-card .member-card-sub { font-size: 12px; color: var(--text-secondary); margin-bottom: 12px; }
.member-card .member-card-stat { font-size: 12px; color: var(--accent); font-weight: 600; }

/* ── Member Header ── */
.member-header { margin-bottom: 28px; }
.member-header h2 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.member-header .member-subtitle { font-size: 13px; color: var(--text-secondary); }
.member-header .member-stat-bar { display: flex; gap: 20px; margin-top: 12px; }
.member-header .stat-item { font-size: 12px; color: var(--text-muted); }
.member-header .stat-item strong { color: var(--text-primary); font-weight: 600; }

/* ── Category Section ── */
.category-section { margin-bottom: 32px; }
.category-header {
  display: flex; align-items: center; gap: 10px; padding: 12px 0;
  border-bottom: 2px solid var(--text-primary); margin-bottom: 16px;
  cursor: pointer; user-select: none;
}
.category-icon { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; font-size: 16px; }
.category-header h3 {
  font-size: 15px; font-weight: 700; flex: 1;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.category-count {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  background: var(--bg-primary); padding: 3px 10px; border: 1px solid var(--border);
}
.category-toggle { color: var(--text-muted); transition: transform 0.3s; }
.category-toggle.collapsed { transform: rotate(-90deg); }
.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.category-grid.collapsed { display: none; }

/* ── Document Card ── */
.doc-card {
  background: var(--bg-card); border: 1px solid var(--border);
  padding: 16px; display: flex; align-items: center; gap: 14px; transition: all var(--transition);
}
.doc-card:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.doc-type-badge {
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; text-transform: uppercase; color: #fff;
  flex-shrink: 0; letter-spacing: 0.3px;
}
.doc-type-badge.pdf { background: #dc2626; }
.doc-type-badge.jpg, .doc-type-badge.jpeg { background: #16a34a; }
.doc-type-badge.png { background: #0891b2; }
.doc-type-badge.txt { background: #6b7280; }
.doc-type-badge.pptx { background: #d97706; }
.doc-type-badge.zip { background: #7c3aed; }
.doc-type-badge.other { background: #64748b; }
.doc-info { flex: 1; min-width: 0; }
.doc-name {
  font-size: 13.5px; font-weight: 500; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; margin-bottom: 3px;
}
.doc-meta { font-size: 11px; color: var(--text-muted); display: flex; gap: 8px; align-items: center; }
.doc-meta .dot { width: 3px; height: 3px; background: var(--text-muted); display: inline-block; }
.doc-actions { display: flex; gap: 6px; flex-shrink: 0; }
.doc-btn {
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: var(--bg-primary);
  color: var(--text-secondary); cursor: pointer; transition: all var(--transition);
}
.doc-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.doc-btn svg { width: 16px; height: 16px; }

/* ── Search Results ── */
.search-results-header { margin-bottom: 20px; }
.search-results-header h2 { font-size: 18px; font-weight: 700; }
.search-results-header p { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.search-results-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.search-result-card {
  background: var(--bg-card); border: 1px solid var(--border);
  padding: 16px; display: flex; align-items: center; gap: 14px; transition: all var(--transition);
}
.search-result-card:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.search-result-card .result-member {
  font-size: 10px; color: var(--accent); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 2px;
}
.no-results { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.no-results h3 { font-size: 18px; margin-bottom: 8px; color: var(--text-secondary); }

/* ── Preview Modal ── */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  z-index: 200; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-container { background: var(--bg-card); width: 100%; max-width: 900px; max-height: 90vh; display: flex; flex-direction: column; }
.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: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; margin-right: 12px; }
.modal-actions { display: flex; gap: 8px; }
.modal-btn {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: var(--bg-primary);
  color: var(--text-secondary); cursor: pointer; transition: all var(--transition);
  text-decoration: none; font-size: 20px;
}
.modal-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.modal-body {
  flex: 1; overflow: auto; display: flex; align-items: center; justify-content: center;
  background: #f8f8f8; min-height: 300px;
}
.modal-body img { max-width: 100%; max-height: 75vh; object-fit: contain; }
.modal-body iframe { width: 100%; height: 75vh; border: none; }
.modal-body .no-preview { text-align: center; padding: 40px; color: var(--text-muted); }
.modal-body .no-preview p { margin-bottom: 16px; }
.modal-body .no-preview a {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 24px;
  background: var(--accent); color: #fff; text-decoration: none; font-size: 13px; font-weight: 600;
}
.modal-body .no-preview a:hover { background: var(--accent-hover); }

/* ── Responsive: Tablet ── */
@media (max-width: 1024px) {
  .content-area { padding: 24px; }
  .category-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
}
/* ── Responsive: Mobile ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .mobile-header { display: flex; }
  .main-content { margin-left: 0; padding-top: 56px; }
  .topbar { padding: 12px 16px; flex-direction: column; gap: 8px; }
  .search-box { max-width: 100%; }
  .content-area { padding: 16px; }
  .category-grid, .search-results-grid { grid-template-columns: 1fr; }
  .member-cards { grid-template-columns: 1fr; }
  .welcome-screen { padding: 40px 12px; }
  .modal-container { max-height: 95vh; }
  .modal-body img { max-height: 60vh; }
  .modal-body iframe { height: 60vh; }
  .doc-card { padding: 14px; gap: 12px; }
  .doc-type-badge { width: 44px; height: 44px; font-size: 11px; }
  .doc-thumb { width: 44px; height: 44px; }
  .doc-name { font-size: 14px; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; margin-bottom: 5px; }
  .doc-meta { font-size: 11.5px; }
  .member-header .member-stat-bar { flex-wrap: wrap; gap: 10px; }
  .pin-box { width: 50px; height: 60px; font-size: 24px; }
}
@media (max-width: 480px) {
  .doc-actions { flex-direction: row; gap: 6px; }
  .doc-btn { width: 32px; height: 32px; }
  .topbar-stats { display: none; }
}
.loading-spinner { display: flex; align-items: center; justify-content: center; padding: 60px; color: var(--text-muted); font-size: 14px; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.3s ease forwards; }

/* ── Thumbnail styles ── */
.doc-thumb {
  width: 44px; height: 44px; flex-shrink: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-primary);
}
.doc-thumb-img {
  width: 44px; height: 44px; object-fit: cover;
  animation: thumbFadeIn 0.3s ease;
}
.thumb-placeholder {
  width: 100%; height: 100%;
}
@keyframes thumbFadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Login button disabled state ── */
.login-btn:disabled {
  opacity: 0.6; cursor: not-allowed;
}
