/* === LinkVault — Premium Minimalist === */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=DM+Mono:wght@400;500&display=swap');

:root {
  --bg: #f8f7f4;
  --surface: #ffffff;
  --surface2: #f2f1ee;
  --border: #e8e6e1;
  --text: #1a1916;
  --text-2: #6b6860;
  --text-3: #a8a49e;
  --accent: #1a1916;
  --accent-hover: #3d3a34;
  --accent-light: #f0efe9;
  --red: #dc2626;
  --red-light: #fef2f2;
  --green: #16a34a;
  --green-light: #f0fdf4;
  --blue: #2563eb;
  --sidebar-w: 248px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg: 0 20px 48px rgba(0,0,0,.12);
  --font: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'DM Mono', monospace;
  --transition: .18s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* === LAYOUT === */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* === SIDEBAR === */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
  transition: transform var(--transition);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.brand-icon {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 16px;
}

.brand-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.3px;
}

.sidebar-nav {
  padding: 12px 10px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius);
  color: var(--text-2);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 2px;
}

.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }

.nav-icon { font-size: 15px; width: 18px; text-align: center; }

.sidebar-section {
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

.sidebar-section-title {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 4px 12px 8px;
}

.nav-folder { padding: 6px 12px; }

.folder-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
}

.user-avatar {
  width: 28px; height: 28px;
  background: var(--accent);
  color: var(--bg);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.logout-btn {
  font-size: 16px;
  text-decoration: none;
  color: var(--text-3);
  transition: color var(--transition);
  padding: 4px;
}
.logout-btn:hover { color: var(--red); }

/* === MAIN === */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  color: var(--text);
}

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

.page-body {
  padding: 28px;
  max-width: 1200px;
}

/* === BUTTONS === */
.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform .1s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: scale(.98); }

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

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
  padding: 9px 18px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

.btn-danger {
  background: var(--red);
  color: white;
  border: none;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition);
}
.btn-danger:hover { opacity: .88; }

.btn-icon {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-3);
  width: 30px; height: 30px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  display: grid;
  place-items: center;
  transition: all var(--transition);
}
.btn-icon:hover { background: var(--surface2); color: var(--text); }
.btn-icon.danger:hover { background: var(--red-light); border-color: var(--red); color: var(--red); }

/* === CARDS === */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card-sm { padding: 14px 16px; border-radius: var(--radius); }

/* === STATS GRID === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  transition: box-shadow var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); }

.stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -1px;
  color: var(--text);
}

.stat-icon { font-size: 20px; margin-bottom: 10px; }

/* === WELCOME === */
.welcome-block {
  margin-bottom: 28px;
}

.welcome-block h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -.5px;
  margin-bottom: 4px;
}

.welcome-block p {
  color: var(--text-2);
  font-size: 14px;
}

/* === LINKS LIST === */
.links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.link-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: box-shadow var(--transition), border-color var(--transition);
}
.link-card:hover { box-shadow: var(--shadow-md); border-color: #d4d2cd; }

.link-favicon {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--surface2);
  display: grid;
  place-items: center;
  font-size: 14px;
  flex-shrink: 0;
  overflow: hidden;
}
.link-favicon img { width: 20px; height: 20px; object-fit: contain; }

.link-info { flex: 1; min-width: 0; }

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

.link-url {
  font-size: 11.5px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-mono);
}

.link-actions { display: flex; gap: 4px; opacity: 0; transition: opacity var(--transition); }
.link-card:hover .link-actions { opacity: 1; }

.link-open {
  text-decoration: none;
  font-size: 14px;
  color: var(--text-3);
  transition: color var(--transition);
}
.link-open:hover { color: var(--blue); }

/* === FOLDER CARDS === */
.folders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.folder-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  cursor: pointer;
  transition: box-shadow var(--transition), border-color var(--transition);
  text-decoration: none;
  color: var(--text);
  display: block;
  position: relative;
  overflow: hidden;
}

.folder-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--folder-color, var(--accent));
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.folder-card:hover { box-shadow: var(--shadow-md); border-color: #d4d2cd; }

.folder-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.folder-icon-big { font-size: 24px; }

.folder-actions-hover {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition);
}
.folder-card:hover .folder-actions-hover { opacity: 1; }

.folder-card-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

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

/* === SECTION HEADER === */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -.3px;
}

/* === EMPTY STATE === */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-3);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: .5;
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 13.5px;
  margin-bottom: 20px;
}

/* === MOST BROWSED === */
.ranked-list { display: flex; flex-direction: column; gap: 10px; }

.rank-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  transition: box-shadow var(--transition);
}
.rank-item:hover { box-shadow: var(--shadow-md); }

.rank-num {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-3);
  font-family: var(--font-mono);
  width: 24px;
  text-align: center;
}

.rank-info { flex: 1; min-width: 0; }

.rank-name {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-url {
  font-size: 11.5px;
  color: var(--text-3);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-badge {
  background: var(--accent-light);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  flex-shrink: 0;
  font-family: var(--font-mono);
}

/* === ACTIVITY TABS === */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface2);
  padding: 4px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  width: fit-content;
}

.tab-btn {
  padding: 6px 16px;
  border: none;
  background: none;
  border-radius: 7px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-2);
  transition: all var(--transition);
}

.tab-btn.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow);
}

/* === FORMS === */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
  letter-spacing: .2px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26,25,22,.06);
}

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

/* === AUTH PAGES === */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg);
  padding: 20px;
}

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

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

.auth-logo-icon {
  width: 44px; height: 44px;
  background: var(--accent);
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 22px;
  margin: 0 auto 12px;
}

.auth-logo h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.4px;
}

.auth-logo p {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 2px;
}

.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-3);
}

.auth-footer a {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
}

.alert-error { background: var(--red-light); color: var(--red); border: 1px solid #fecaca; }
.alert-success { background: var(--green-light); color: var(--green); border: 1px solid #bbf7d0; }

.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

/* === MODAL === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.3);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  place-items: center;
  padding: 20px;
  animation: fadeIn .15s ease;
}

.modal-overlay.open { display: grid; }

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

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease;
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

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

.modal-close {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--text-3);
  padding: 2px 6px;
  border-radius: 4px;
  transition: all var(--transition);
}
.modal-close:hover { background: var(--surface2); color: var(--text); }

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

.delete-msg {
  font-size: 13.5px;
  color: var(--text-2);
  margin-bottom: 8px;
}

/* === COLOR PICKER === */
.color-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.color-swatch {
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  transition: transform var(--transition);
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch input { position: absolute; opacity: 0; width: 0; height: 0; }
.color-swatch input:checked + .check-mark,
.color-swatch:has(input:checked) { outline: 3px solid var(--text); outline-offset: 2px; }

/* === TOAST === */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: slideUp .25s ease;
  pointer-events: auto;
}

.toast.success { background: var(--green); }
.toast.error { background: var(--red); }

/* === PAGE HEADER === */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.page-header h2 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -.4px;
}

.page-header p {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 3px;
}

/* === FOLDER DETAIL === */
.breadcrumb {
  font-size: 13px;
  color: var(--text-3);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.breadcrumb a { color: var(--text-2); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); }

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }

  .main-content { margin-left: 0; }
  .hamburger { display: block; }
  .page-body { padding: 16px; }

  .links-grid { grid-template-columns: 1fr; }
  .folders-grid { grid-template-columns: 1fr 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .auth-card { padding: 24px 20px; }

  .topbar { padding: 10px 16px; }
}

@media (max-width: 480px) {
  .folders-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* === MISC === */
.text-muted { color: var(--text-3); }
.text-sm { font-size: 12.5px; }
.mt-0 { margin-top: 0 !important; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.3);
  z-index: 99;
}
.sidebar-overlay.show { display: block; }
