/*
Theme Name: Clever Bookmarks 2.0
Theme URI: https://book.clever.ws
Author: Rob Clever
Description: Bookmark dashboard - media library is the tile hub. Image description = URL, caption = private notes.
Version: 2.0
*/

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f0f2f5;
  padding: 16px;
  min-height: 100vh;
}

.wrapper { max-width: 1400px; margin: 0 auto; }

/* ── LOGIN ── */
.login-screen {
  display: flex; align-items: center; justify-content: center; min-height: 80vh;
}
.login-box {
  background: #fff; border-radius: 12px; padding: 40px 36px;
  width: 100%; max-width: 360px;
  box-shadow: 0 4px 24px rgba(0,0,0,.10); text-align: center;
}
.login-box h2 { font-size: 1.4rem; margin-bottom: 24px; color: #1a1a2e; }
.login-box input {
  width: 100%; padding: 10px 14px; border: 1px solid #ddd;
  border-radius: 8px; font-size: .95rem; margin-bottom: 14px; outline: none;
}
.login-box input:focus { border-color: #4285f4; }
.login-btn {
  width: 100%; padding: 11px; background: #4285f4; color: #fff;
  border: none; border-radius: 8px; font-size: 1rem; cursor: pointer; font-weight: 600;
}
.login-btn:hover { background: #2c6fdb; }
.login-error { color: #ea4335; font-size: .88rem; margin-top: 10px; display: none; }

/* ── HEADER ── */
.page-header {
  display: flex; align-items: center; justify-content: space-between; padding: 14px 0 10px;
}
.page-header h1 { font-size: 1.3rem; color: #1a1a2e; display: flex; align-items: center; gap: 8px; }
.header-icon { width: 32px; height: 32px; border-radius: 6px; object-fit: contain; }
.header-right { display: flex; align-items: center; gap: 12px; }
.user-badge {
  font-size: .85rem; color: #555; background: #e8f0fe; padding: 5px 12px; border-radius: 20px;
}
.logout-btn {
  font-size: .82rem; color: #ea4335; background: none;
  border: 1px solid #ea4335; border-radius: 20px; padding: 5px 12px; cursor: pointer;
}
.logout-btn:hover { background: #fce8e6; }

/* ── SEARCH ── */
.search-bar { margin: 10px 0; }
.search-bar input {
  width: 100%; padding: 10px 16px; border: 1px solid #ddd;
  border-radius: 24px; font-size: .95rem; outline: none; background: #fff;
}
.search-bar input:focus { border-color: #4285f4; }

/* ── EXPAND ALL TOGGLE ── */
.expand-bar { margin-bottom: 10px; display: flex; align-items: center; }
.expand-toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.expand-toggle input { display: none; }
.expand-slider {
  width: 42px; height: 24px; background: #ccc; border-radius: 24px;
  position: relative; transition: background .2s; flex-shrink: 0;
}
.expand-slider::after {
  content: ''; position: absolute; width: 18px; height: 18px;
  background: #fff; border-radius: 50%; top: 3px; left: 3px;
  transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.expand-toggle input:checked + .expand-slider { background: #34a853; }
.expand-toggle input:checked + .expand-slider::after { transform: translateX(18px); }
.expand-label { font-size: .85rem; color: #555; }

/* ── SECTIONS ── */
.section { margin-bottom: 8px; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.section.hidden { display: none; }

.section-header {
  display: flex; align-items: center; justify-content: space-between;
  background: #fff; padding: 11px 16px; cursor: pointer; user-select: none;
  border-bottom: 1px solid transparent; transition: background .15s;
}
.section-header:hover { background: #f8f9ff; }
.section-header.open { border-bottom-color: #e8eaed; }
.section-title { font-size: .92rem; font-weight: 700; color: #1a1a2e; }
.section-count { font-size: .78rem; color: #888; margin-left: 8px; font-weight: 400; }
.section-chevron { font-size: .75rem; color: #bbb; transition: transform .2s; }
.section-header.open .section-chevron { transform: rotate(90deg); }
.drag-handle { cursor: grab; font-size: .85rem; color: #ccc; margin-right: 6px; }
.drag-handle:hover { color: #888; }

.section-body { display: none; background: #fff; padding: 12px; }
.section-body.open { display: block; }

/* ── TILES ── */
.grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 20px;
}

@media (max-width: 768px) {
  .grid {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: thin;
    scrollbar-color: #ddd transparent;
  }
  .grid::-webkit-scrollbar { height: 5px; }
  .grid::-webkit-scrollbar-track { background: transparent; }
  .grid::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }
  .grid::-webkit-scrollbar-thumb:hover { background: #bbb; }
}

.tile {
  position: relative; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-start;
  width: 110px; padding: 10px 6px 8px; border-radius: 10px;
  text-decoration: none; background: #f8f9fa;
  border: 1px solid #e8eaed;
  transition: background .15s, box-shadow .15s, transform .15s;
  cursor: pointer; transform-origin: center center;
}
.tile:hover {
  background: #e8f0fe; box-shadow: 0 4px 16px rgba(66,133,244,.22);
  transform: scale(1.08); z-index: 10;
}
.tile.hidden { display: none; }
.tile.dragging { opacity: 0.4; }
.tile.drag-over { outline: 2px dashed #4285f4; background: #e8f0fe; }

.tile img {
  width: 64px; height: 64px; border-radius: 8px;
  object-fit: contain; margin-bottom: 6px;
}
.tile-label {
  font-size: .68rem; color: #444; text-align: center;
  line-height: 1.3; word-break: break-word; max-width: 100%;
}
.tile-note-icon {
  position: absolute; top: 3px; left: 5px;
  font-size: .65rem; color: #fbbc05; display: none;
}
.tile[data-has-note="1"] .tile-note-icon { display: block; }

.tile-delete {
  position: absolute; top: 2px; right: 4px; font-size: .75rem;
  color: #aaa; display: none; cursor: pointer; line-height: 1; background: none; border: none;
  z-index: 20;
}
.tile:hover .tile-delete { display: block; }
.tile-delete:hover { color: #ea4335; }

/* note tooltip */
.tile-note-tip {
  display: none; position: absolute; bottom: 100%; left: 50%;
  transform: translateX(-50%); background: #333; color: #fff;
  font-size: .72rem; padding: 4px 8px; border-radius: 6px;
  white-space: nowrap; z-index: 100; pointer-events: none; margin-bottom: 4px;
  max-width: 200px; white-space: normal; text-align: center;
}
.tile:hover .tile-note-tip { display: block; }

.section-drag-over { outline: 2px dashed #34a853; }

/* ── TOAST ── */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #333; color: #fff; padding: 10px 22px;
  border-radius: 24px; font-size: .88rem;
  transition: transform .3s; z-index: 9999; pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.green { background: #34a853; }

/* ── DELETE CONFIRM MODAL ── */
.bm-modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.45); z-index: 99999;
  align-items: center; justify-content: center;
}
.bm-modal-overlay.active { display: flex; }
.bm-modal {
  background: #fff; border-radius: 12px;
  padding: 28px 32px; max-width: 340px; width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,.22);
  text-align: center;
}
.bm-modal h3 { margin: 0 0 10px; font-size: 1.05rem; color: #1b2b47; }
.bm-modal p  { margin: 0 0 22px; font-size: .9rem; color: #555; line-height: 1.5; }
.bm-modal-btns { display: flex; gap: 10px; justify-content: center; }
.bm-modal-btns button {
  padding: 9px 22px; border-radius: 8px; border: none;
  font-size: .9rem; font-weight: 600; cursor: pointer;
}
.bm-btn-cancel { background: #f1f3f4; color: #444; }
.bm-btn-cancel:hover { background: #e2e5e9; }
.bm-btn-delete { background: #ea4335; color: #fff; }
.bm-btn-delete:hover { background: #c5372c; }

/* ── LOADING ── */
.loading-msg { text-align: center; padding: 40px; color: #888; font-size: .95rem; }

@media (max-width: 600px) {
  .tile { width: 88px; }
  .tile img { width: 52px; height: 52px; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 8px; }
}
