/*
Theme Name: BookTheme
Theme URI: https://book.clever.ws
Author: Rob Clever
Author URI: https://clever.ws
Description: Personal bookmark dashboard with collapsible sections, favicon tiles, and database storage.
Version: 2.7
License: GNU General Public License v2 or later
Text Domain: booktheme
*/

* { 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: 1200px; 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; }
.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; }

/* ── ADD BAR ── */
.add-bar {
  background: #fff; border-radius: 10px; padding: 14px 16px; margin-bottom: 14px;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.add-bar input, .add-bar select {
  padding: 8px 12px; border: 1px solid #ddd; border-radius: 8px;
  font-size: .88rem; outline: none; background: #fff;
}
.add-bar input:focus, .add-bar select:focus { border-color: #4285f4; }
.add-bar .input-url { flex: 2; min-width: 160px; }
.add-bar .input-label { flex: 1; min-width: 120px; }
.add-bar select { flex: 1; min-width: 140px; }
.add-btn {
  padding: 8px 18px; background: #34a853; color: #fff;
  border: none; border-radius: 8px; font-size: .88rem; font-weight: 600; cursor: pointer;
}
.add-btn:hover { background: #2a8a43; }

/* ── 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); }

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

/* ── TILES ── */
.grid { display: flex; flex-wrap: wrap; gap: 8px; }

.tile {
  position: relative; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-start;
  width: 96px; 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.13);
  z-index: 10;
}
.tile.hidden { display: none; }

.tile-favicon {
  width: 36px; height: 36px; border-radius: 8px; object-fit: contain; margin-bottom: 6px;
}
.tile-fallback {
  width: 36px; height: 36px; border-radius: 8px; display: flex;
  align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 1.1rem; 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-delete {
  position: absolute; top: 2px; right: 4px; font-size: .75rem;
  color: #aaa; display: none; cursor: pointer; line-height: 1;
}
.tile:hover .tile-delete { display: block; }
.tile-delete:hover { color: #ea4335; }
.drag-over-tile { outline: 2px dashed #4285f4; background: #e8f0fe; }
.section-drag-over { outline: 2px dashed #34a853; }
.drag-handle { cursor: grab; font-size: .85rem; color: #ccc; margin-right: 4px; }
.drag-handle:hover { color: #888; }



/* URL tiles grid */
.urls-grid {
  display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 0;
}
.url-tile {
  position: relative; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-start;
  width: 96px; padding: 10px 6px 8px; border-radius: 10px;
  text-decoration: none; background: #f0f7ff;
  border: 1px solid #c5d8f5;
  transition: background .15s, box-shadow .15s, transform .15s;
  cursor: pointer; transform-origin: center center;
}
.url-tile:hover {
  background: #dbeafe; box-shadow: 0 4px 16px rgba(66,133,244,.22);
  transform: scale(1.13); z-index: 10;
}
.url-tile-favicon {
  width: 36px; height: 36px; border-radius: 8px; object-fit: contain; margin-bottom: 6px;
}
.url-tile-fallback {
  width: 36px; height: 36px; border-radius: 8px; display: flex;
  align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 1.1rem; margin-bottom: 6px;
  background: #4285f4;
}
.url-tile-label {
  font-size: .68rem; color: #1a56db; text-align: center;
  line-height: 1.3; word-break: break-word; max-width: 100%; font-weight: 600;
}
.url-tile-copy {
  position: absolute; bottom: 3px; right: 4px;
  font-size: .58rem; background: #4285f4; color: #fff;
  border: none; border-radius: 4px; padding: 1px 5px;
  cursor: pointer; display: none; line-height: 1.6;
}
.url-tile:hover .url-tile-copy { display: block; }
.url-tile-copy:hover { background: #2c6fdb; }
.url-tile-delete {
  position: absolute; top: 2px; right: 4px; font-size: .75rem;
  color: #aaa; display: none; cursor: pointer; line-height: 1;
}
.url-tile:hover .url-tile-delete { display: block; }
.url-tile-delete:hover { color: #ea4335; }
.urls-empty { font-size: .85rem; color: #aaa; padding: 8px 0; }

/* ── 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: 999; pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.green { background: #34a853; }

@media (max-width: 600px) {
  .add-bar { flex-direction: column; }
  .add-bar input, .add-bar select, .add-btn { width: 100%; }
  .tile { width: 80px; }
  .url-tile { width: 80px; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .urls-add-bar { flex-direction: column; }
  .urls-add-bar input, .urls-add-btn { width: 100%; }
}
