/* public/style.css — Light-/Dark-Mode Design, angelehnt an Docmost-Dashboard */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

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

:root {
  /* Light (Standard) */
  color-scheme: light;
  --bg-page: #f5f6f8;
  --bg-surface: #ffffff;
  --bg-elevated: #f0f1f4;
  --bg-input: #ffffff;
  --border: #e2e4e9;
  --border-hover: #c9ccd4;
  --border-focus: #3b6ef5;
  --text: #1f2329;
  --text-secondary: #5b616e;
  --text-muted: #8a909c;
  --accent: #3b6ef5;
  --accent-hover: #2f5fe0;
  --success: #2ecc71;
  --error: #e74c3c;
  --shadow-topbar: 0 1px 0 rgba(16, 24, 40, 0.03);
  --shadow-card: 0 8px 20px rgba(16, 24, 40, 0.08);
  --shadow-dropdown: 0 8px 24px rgba(16, 24, 40, 0.1);
  --shadow-modal: 0 16px 40px rgba(16, 24, 40, 0.12);
  --backdrop: rgba(15, 20, 30, 0.35);
  --radius: 8px;
  --transition: 0.15s ease;
  --topbar-height: 56px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg-page: #111318;
  --bg-surface: #1b1d24;
  --bg-elevated: #23262f;
  --bg-input: #1b1d24;
  --border: #2e3039;
  --border-hover: #3a3d47;
  --border-focus: #4a7cff;
  --text: #d8dae0;
  --text-secondary: #9095a0;
  --text-muted: #5d616c;
  --accent: #4a7cff;
  --accent-hover: #5d8bff;
  --shadow-topbar: 0 1px 0 rgba(0, 0, 0, 0.2);
  --shadow-card: 0 8px 20px rgba(0, 0, 0, 0.35);
  --shadow-dropdown: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-modal: 0 16px 40px rgba(0, 0, 0, 0.45);
  --backdrop: rgba(0, 0, 0, 0.55);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-page);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ========== Topbar ========== */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-topbar);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-img {
  display: block;
  width: auto;
  box-sizing: border-box;
  padding: 3px 7px;
  border-radius: 6px;
}
:root[data-theme="dark"] .logo-img { filter: invert(1) hue-rotate(180deg); }
.topbar .logo-img { height: 32px; }

.topbar-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

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

/* ========== Buttons ========== */
button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  transition: background-color var(--transition), color var(--transition), border-color var(--transition);
}

[hidden] { display: none !important; }

.btn {
  display: inline-block;
  padding: 8px 16px;
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  background-color: var(--accent);
  color: #fff;
  border-radius: var(--radius);
}
.btn:hover { background-color: var(--accent-hover); }
.btn:active { background-color: #3d6de0; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary {
  background-color: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { color: var(--text); background-color: var(--bg-elevated); border-color: var(--text-muted); }

.icon-btn {
  background: transparent;
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}
.icon-btn:hover { color: var(--error); background-color: rgba(231, 76, 60, 0.12); }

.theme-toggle {
  background: transparent;
  color: var(--text-secondary);
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
}
.theme-toggle:hover { color: var(--text); background-color: var(--bg-elevated); border-color: var(--text-muted); }
.theme-toggle .icon-moon { display: block; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

.theme-toggle-floating {
  position: fixed;
  top: 12px;
  right: 16px;
}

/* ========== Main content ========== */
.main-content {
  padding-top: calc(var(--topbar-height) + 40px);
  padding-left: 32px;
  padding-right: 32px;
  padding-bottom: 48px;
  max-width: 1100px;
  margin: 0 auto;
}

.category-section {
  margin-bottom: 36px;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  margin-bottom: 14px;
}

.category-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.category-move {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}
.category-section:hover .category-move,
.category-move:focus-within { opacity: 1; }
.category-move .icon-btn:hover { color: var(--text); background-color: var(--bg-elevated); }
.category-move .icon-btn:disabled { opacity: 0.3; cursor: default; background: transparent; color: var(--text-muted); }

/* ========== Link grid ========== */
.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.link-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  text-decoration: none;
  color: var(--text);
  transition: border-color var(--transition), background-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.link-card:hover {
  border-color: var(--border-focus);
  background-color: var(--bg-elevated);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}

.link-favicon-wrap {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  flex-shrink: 0;
  overflow: hidden;
}

:root:not([data-theme="dark"]) .link-favicon-wrap {
  border: 1px solid var(--border);
}

.link-favicon {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 6px;
  background-color: #fff;
}

.link-favicon-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
}

.link-favicon-emoji {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
}

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

.link-title {
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-desc {
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--text-secondary);
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.link-card-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--transition);
}

.link-card:hover .link-card-actions {
  opacity: 1;
}

.link-edit:hover {
  color: var(--accent);
  background-color: rgba(74, 124, 255, 0.12);
}

/* Add-link tile: matches card grid, opens the form */
.add-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background-color: transparent;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 500;
  width: 100%;
}

.add-card:hover {
  border-color: var(--accent);
  color: var(--accent);
  background-color: var(--bg-surface);
}

.empty-state {
  color: var(--text-muted);
  font-size: 0.8125rem;
  padding: 40px 0;
  text-align: center;
}

/* ========== Modal ========== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: var(--backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-modal);
}

.modal h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group {
  flex: 1;
  min-width: 0;
}

.form-group-icon {
  max-width: 90px;
}

.form-group-icon input {
  text-align: center;
  font-size: 1.125rem;
}

.input-hint {
  display: block;
  margin-top: -6px;
  margin-bottom: 16px;
  color: var(--text-muted);
  font-size: 0.75rem;
}

label {
  margin-bottom: 6px;
  font-weight: 500;
  font-size: 0.75rem;
  color: var(--text-secondary);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

input {
  font-family: inherit;
  background-color: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 0.875rem;
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
}

input:hover { border-color: var(--border-hover); }
input:focus { border-color: var(--border-focus); }
input::placeholder { color: var(--text-muted); }

/* ========== Searchable Dropdown ========== */
.searchable-dropdown {
  position: relative;
  width: 100%;
}

.searchable-dropdown .search-input {
  width: 100%;
}

.dropdown-list {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 160px;
  overflow-y: auto;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 50;
  box-shadow: var(--shadow-dropdown);
}

.dropdown-list.open {
  display: block;
}

.dropdown-item {
  padding: 8px 12px;
  font-size: 0.875rem;
  color: var(--text);
  cursor: pointer;
  transition: background-color var(--transition);
}

.dropdown-item:hover {
  background-color: rgba(74, 124, 255, 0.1);
}

.dropdown-item.empty {
  color: var(--text-muted);
  cursor: default;
  font-style: italic;
}

.dropdown-item.empty:hover {
  background-color: transparent;
}

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

.form-error {
  font-size: 0.8125rem;
  color: var(--error);
  background-color: rgba(231, 76, 60, 0.1);
  border-left: 3px solid var(--error);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 16px;
  display: none;
}
.form-error.show { display: block; }

/* ========== Auth pages (login) ========== */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding-top: 0;
}

.auth-container {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow-modal);
}

.auth-container h1 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.auth-container p {
  color: var(--text-secondary);
  font-size: 0.8125rem;
  margin-bottom: 24px;
}

.auth-btn {
  width: 100%;
  padding: 10px;
  font-size: 0.8125rem;
  font-weight: 500;
  background-color: var(--accent);
  color: #fff;
}
.auth-back {
  display: block;
  text-align: center;
  margin-top: 16px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-decoration: none;
}
.auth-back:hover { color: var(--text); }

.auth-btn:hover { background-color: var(--accent-hover); }
.auth-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.auth-message {
  font-size: 0.8125rem;
  color: var(--error);
  background-color: rgba(231, 76, 60, 0.1);
  border-left: 3px solid var(--error);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 16px;
  display: none;
}
.auth-message.show { display: block; }

@media (max-width: 500px) {
  .main-content { padding-left: 16px; padding-right: 16px; }
  .topbar { padding: 0 16px; }
}
