/* ── Moj Svet — style.css ── */
.hidden { display: none; }
:root {
  --bg:      #0f172a;
  --surface: #1e293b;
  --surface2:#263348;
  --border:  #334155;
  --border-h:#475569;
  --text:    #f1f5f9;
  --text-sec:#94a3b8;
  --primary: #3b82f6;
  --primary-h:#2563eb;
  --primary-light: rgba(59,130,246,.15);
  --danger:  #ef4444;
  --success: #22c55e;
  --radius:  10px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; }
a { color: inherit; text-decoration: none; }
input, button, select { font-family: inherit; font-size: inherit; }

/* ── Login ── */
.public-login-section {
  border-top: 1px solid var(--border); margin-top: 3rem;
  display: flex; justify-content: center; padding: 3rem 1rem 5rem;
}

.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: linear-gradient(135deg, #080d1a 0%, #0f1f3a 50%, #080d1a 100%); }
.login-wrap { width: 100%; max-width: 380px; padding: 2.5rem 2rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.login-logo { font-size: 1.6rem; font-weight: 800; color: var(--primary); margin-bottom: .25rem; display: flex; align-items: center; gap: .5rem; }
.login-title { font-size: .88rem; color: var(--text-sec); margin-bottom: 1.75rem; }
.nacin-preklop { display: flex; background: var(--surface2); border-radius: 8px; padding: .2rem; margin-bottom: 1.5rem; }
.nacin-btn { flex: 1; padding: .45rem; border-radius: 6px; border: none; background: transparent;
  color: var(--text-sec); font-size: .87rem; font-weight: 600; cursor: pointer; transition: background .15s, color .15s; }
.nacin-btn.active { background: var(--primary); color: #fff; }
.alert-error { background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3); color: #fca5a5;
  border-radius: 7px; padding: .6rem .85rem; font-size: .85rem; margin-bottom: 1rem; }
.field { margin-bottom: .9rem; }
.field label { display: block; font-size: .82rem; font-weight: 500; color: var(--text-sec); margin-bottom: .35rem; }
.field label small { font-weight: 400; }
.field input, .field select { width: 100%; padding: .6rem .85rem; background: var(--surface2); border: 1.5px solid var(--border);
  color: var(--text); border-radius: 8px; transition: border-color .15s; }
.field input:focus, .field select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.field select option { background: var(--surface2); }
.btn-submit { width: 100%; padding: .75rem; background: var(--primary); color: #fff; border: none;
  border-radius: 8px; font-size: .92rem; font-weight: 700; cursor: pointer; letter-spacing: .04em;
  transition: background .15s; margin-top: .4rem; }
.btn-submit:hover { background: var(--primary-h); }

/* ── App header ── */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 1.25rem; gap: 1rem;
}
.app-logo { font-size: 1.05rem; font-weight: 800; color: var(--primary); flex-shrink: 0; display: flex; align-items: center; gap: .4rem; }
.app-logo span { color: var(--text); }

.search-section { flex: 1; display: flex; flex-direction: column; gap: .3rem; max-width: 620px; margin: 0 auto; }
.engine-bar { display: flex; gap: .3rem; flex-wrap: wrap; }
.engine-btn {
  padding: .18rem .65rem; border-radius: 20px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text-sec); font-size: .75rem; font-weight: 600;
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.engine-btn:hover { border-color: var(--primary); color: var(--primary); }
.engine-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.search-bar { display: flex; gap: .4rem; }
.search-bar input {
  flex: 1; padding: .45rem .9rem; background: var(--surface2);
  border: 1.5px solid var(--border); color: var(--text); border-radius: 8px;
  transition: border-color .15s;
}
.search-bar input:focus { outline: none; border-color: var(--primary); }
.search-btn { padding: .45rem 1rem; background: var(--primary); color: #fff; border: none;
  border-radius: 8px; cursor: pointer; font-weight: 700; transition: background .15s; }
.search-btn:hover { background: var(--primary-h); }

.header-right { display: flex; align-items: center; gap: .65rem; flex-shrink: 0; font-size: .85rem; color: var(--text-sec); }
.header-user { font-weight: 600; color: var(--text); }
.btn-ghost { background: none; border: 1px solid var(--border); color: var(--text-sec);
  border-radius: 7px; padding: .28rem .65rem; cursor: pointer; transition: all .15s; white-space: nowrap; }
.btn-ghost:hover { border-color: var(--border-h); color: var(--text); }
.btn-sm { font-size: .8rem; }

/* ── Main nav (3 sections) ── */
.main-nav {
  position: fixed; top: 56px; left: 0; right: 0; z-index: 99;
  height: 44px; background: var(--bg); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 1.25rem; gap: .2rem;
}
.main-nav-btn {
  padding: .38rem 1rem; border-radius: 7px; border: none;
  background: transparent; color: var(--text-sec); font-size: .88rem; font-weight: 600;
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.main-nav-btn:hover { background: var(--surface); color: var(--text); }
.main-nav-btn.active { background: var(--primary-light); color: var(--primary); }

/* ── Main ── */
.app-main { margin-top: 100px; padding: 1.25rem 1.5rem 5rem; min-height: calc(100vh - 100px); }

/* ── Moje login wall ── */
.moje-login-wall {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 5rem 2rem; text-align: center; gap: .75rem;
}
.moje-login-icon { font-size: 3rem; margin-bottom: .5rem; }
.moje-login-title { font-size: 1.3rem; font-weight: 700; color: var(--text); }
.moje-login-sub { font-size: .92rem; color: var(--text-sec); max-width: 360px; line-height: 1.6; }

/* ── Tabs bar ── */
.tabs-bar { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1.25rem; align-items: center; }

.tab-item { position: relative; display: inline-flex; }
.tab-icon-btn {
  position: absolute; top: 4px;
  border: none; border-radius: 4px; background: transparent;
  color: var(--text-sec); width: 16px; height: 16px; font-size: .65rem; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  padding: 0; opacity: .45; transition: opacity .12s, background .12s, color .12s; z-index: 1;
}
.tab-edit-btn { left: 4px; }
.tab-del-btn { right: 4px; }
.tab-icon-btn:hover { opacity: 1; background: var(--border-h); color: var(--text); }
.tab-del-btn:hover { background: rgba(239,68,68,.25); color: var(--danger); }

.tab-btn {
  padding: 1.35rem .75rem .45rem; min-width: 60px; text-align: center;
  border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text-sec); font-size: .85rem; font-weight: 500;
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.tab-btn:hover { background: var(--surface); color: var(--text); border-color: var(--border-h); }
.tab-btn.active { background: var(--primary-light); color: var(--primary); border-color: rgba(59,130,246,.3); font-weight: 700; }
.tab-add { padding: .32rem .7rem; border-radius: 7px; border: 1px dashed var(--border-h);
  background: transparent; color: var(--text-sec); font-size: .82rem; cursor: pointer;
  transition: all .15s; }
.tab-add:hover { border-color: var(--primary); color: var(--primary); }
.tab-rename-input { padding: .32rem .55rem; border-radius: 6px; border: 1.5px solid var(--primary);
  background: var(--surface2); color: var(--text); font-size: .88rem; font-family: inherit; width: 120px; }

/* ── Links grid ── */
.links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.link-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-direction: column; overflow: hidden;
  transition: border-color .2s, transform .2s, box-shadow .2s;
  position: relative; min-height: 90px;
}
.link-card:hover { border-color: var(--primary); transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(59,130,246,.14); }
.link-card-body {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.25rem 1.4rem; flex: 1; min-width: 0;
}
.link-favicon {
  width: 40px; height: 40px; border-radius: 8px; flex-shrink: 0;
  object-fit: contain; background: var(--surface2); padding: 4px;
}
.link-info { min-width: 0; flex: 1; }
.link-title { font-size: .97rem; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-domain { font-size: .78rem; color: var(--text-sec); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: .2rem; }

.link-actions {
  display: none; position: absolute; top: .5rem; right: .5rem; gap: .25rem;
}
.link-card:hover .link-actions { display: flex; }
.link-action-btn {
  border: none; border-radius: 6px; width: 26px; height: 26px; font-size: .82rem;
  cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0;
  transition: background .12s;
}
.link-edit { background: rgba(59,130,246,.15); color: var(--primary); }
.link-edit:hover { background: rgba(59,130,246,.35); }
.link-del  { background: rgba(239,68,68,.12);  color: var(--danger); }
.link-del:hover  { background: rgba(239,68,68,.32); }

.empty-state { text-align: center; padding: 4rem 2rem; color: var(--text-sec); font-size: .92rem; grid-column: 1/-1; }
.empty-state strong { color: var(--text); }

/* ── FAB ── */
.fab {
  position: fixed; bottom: 2rem; right: 2rem; z-index: 200;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--primary); color: #fff; border: none;
  font-size: 1.5rem; font-weight: 300; cursor: pointer;
  box-shadow: 0 4px 16px rgba(59,130,246,.4);
  transition: background .15s, box-shadow .15s, transform .15s;
}
.fab:hover { background: var(--primary-h); transform: scale(1.07); box-shadow: 0 6px 22px rgba(59,130,246,.55); }

/* ── Modal ── */
.modal-overlay { position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; }
.modal-overlay.hidden { display: none; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 1.75rem; width: 100%; max-width: 420px;
  box-shadow: 0 16px 48px rgba(0,0,0,.5); }
.modal-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 1.25rem; }
.field-note { font-size: .82rem; color: var(--text-sec); margin-bottom: .9rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .65rem; margin-top: 1.5rem; }
.btn-primary { padding: .5rem 1.2rem; background: var(--primary); color: #fff; border: none;
  border-radius: 8px; font-weight: 700; cursor: pointer; transition: background .15s; }
.btn-primary:hover { background: var(--primary-h); }
.btn-danger { padding: .5rem 1.2rem; background: rgba(239,68,68,.15); color: var(--danger);
  border: 1px solid rgba(239,68,68,.3); border-radius: 8px; font-weight: 700; cursor: pointer; transition: background .15s; }
.btn-danger:hover { background: rgba(239,68,68,.3); }

/* Engine toggles in settings */
#engine-toggles { display: flex; flex-direction: column; gap: .55rem; }
.engine-toggle { display: flex; align-items: center; gap: .55rem; cursor: pointer;
  font-size: .88rem; color: var(--text); padding: .35rem 0; }
.engine-toggle input { width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; }

/* ── Notes icon on card ── */
.link-notes-btn { background: rgba(250,204,21,.1); color: #a16207; }
.link-notes-btn:hover { background: rgba(250,204,21,.28); color: #854d0e; }
.link-notes-btn.has-notes { background: rgba(250,204,21,.3); color: #854d0e; }

/* ── Notes modal ── */
.modal-notes-inner { max-width: 480px; }
.notes-input-row { display: flex; gap: .6rem; align-items: flex-start; margin-bottom: 1rem; }
.notes-input-row textarea {
  flex: 1; padding: .55rem .9rem; background: var(--surface2);
  border: 1.5px solid var(--border); color: var(--text); border-radius: 8px;
  font-family: inherit; font-size: .9rem; resize: vertical; min-height: 56px;
  transition: border-color .15s;
}
.notes-input-row textarea:focus { outline: none; border-color: var(--primary); }
.notes-list { display: flex; flex-direction: column; gap: .4rem; max-height: 320px; overflow-y: auto; }
.note-item {
  background: var(--surface2); border: 1px solid var(--border); border-radius: 8px;
  padding: .6rem .85rem; display: flex; gap: .5rem; align-items: flex-start;
}
.note-item-content { flex: 1; font-size: .9rem; color: var(--text); white-space: pre-wrap; line-height: 1.5; word-break: break-word; }
.note-edit-ta {
  flex: 1; width: 100%; padding: .4rem .65rem; background: var(--surface);
  border: 1.5px solid var(--primary); color: var(--text); border-radius: 6px;
  font-family: inherit; font-size: .9rem; resize: vertical; min-height: 48px;
}
.note-item-actions { display: flex; gap: .25rem; flex-shrink: 0; }
.note-item-btn {
  border: none; border-radius: 5px; width: 22px; height: 22px; font-size: .8rem;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  padding: 0; transition: background .12s; line-height: 1;
}
.note-item-edit   { background: rgba(59,130,246,.12);  color: var(--primary); }
.note-item-edit:hover   { background: rgba(59,130,246,.3); }
.note-item-del    { background: rgba(239,68,68,.1);    color: var(--danger); }
.note-item-del:hover    { background: rgba(239,68,68,.28); }
.note-item-save   { background: rgba(34,197,94,.15);   color: #16a34a; }
.note-item-save:hover   { background: rgba(34,197,94,.32); }
.note-item-cancel { background: rgba(156,163,175,.15); color: var(--text-sec); }
.note-item-cancel:hover { background: rgba(156,163,175,.3); }

/* ── Stats icon ── */
.stats-icon-btn {
  border: none; background: transparent; color: var(--text-sec); font-size: 1.1rem;
  cursor: pointer; padding: .2rem .4rem; border-radius: 7px; flex-shrink: 0;
  transition: color .15s, background .15s;
}
.stats-icon-btn:hover { color: var(--text); background: var(--surface2); }

/* ── Stats overlay ── */
.stats-overlay {
  position: fixed; inset: 0; z-index: 300; background: var(--bg);
  overflow-y: auto; padding: calc(56px + 1.25rem) 1.5rem 3rem;
}
.stats-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.75rem; gap: 1rem;
}
.stats-title { font-size: 1.2rem; font-weight: 800; color: var(--text); margin: 0; }
.stats-section { margin-bottom: 2rem; }
.stats-section-title { font-size: .95rem; font-weight: 700; color: var(--text-sec); text-transform: uppercase; letter-spacing: .05em; margin: 0 0 .75rem; }
.stats-tab-block { margin-bottom: 1.25rem; }
.stats-tab-name {
  display: flex; align-items: center; gap: .6rem;
  font-size: 1rem; font-weight: 700; color: var(--text); margin-bottom: .4rem;
}
.stats-link-list { display: flex; flex-direction: column; gap: .3rem; }
.stats-link-list.indent { padding-left: 1.5rem; }
.stats-link-row {
  display: flex; align-items: center; gap: .65rem; text-decoration: none;
  padding: .45rem .75rem; border-radius: 8px; background: var(--surface);
  border: 1px solid var(--border); transition: border-color .15s, transform .15s;
}
.stats-link-row:hover { border-color: var(--primary); transform: translateX(3px); }
.stats-rank { font-size: .75rem; font-weight: 700; color: var(--text-sec); min-width: 1.4rem; text-align: right; }
.stats-fav { width: 20px; height: 20px; border-radius: 4px; flex-shrink: 0; }
.stats-link-title { flex: 1; font-size: .88rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats-clicks { font-size: .78rem; font-weight: 700; color: var(--primary); flex-shrink: 0; }
.stats-empty { font-size: .88rem; color: var(--text-sec); margin: .5rem 0; }
.stats-loading { color: var(--text-sec); padding: 2rem 0; }

/* ── Logo mode label ── */
.app-logo { cursor: pointer; }
.logo-mode-label {
  font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-sec); margin-left: .55rem; align-self: center;
  transition: color .2s, text-shadow .2s;
}
.app-logo.logo-active { color: var(--primary); }
.app-logo.logo-active > span { color: var(--primary); }
.app-logo.logo-active .logo-mode-label {
  color: var(--primary);
  text-shadow: 0 0 8px rgba(59,130,246,.8), 0 0 20px rgba(59,130,246,.45);
}

/* ── Shared view ── */
.shared-bar { margin-bottom: .75rem; }
.shared-title { font-size: 1.1rem; font-weight: 700; color: var(--text); margin: 0 0 .2rem; }
.shared-subtitle { font-size: .8rem; color: var(--text-sec); margin: 0; }
.shared-tabs-bar .tab-btn { padding: .38rem .85rem; }
.shared-tabs-bar .tab-item { position: static; display: inline-flex; }
.link-card-ro { text-decoration: none; display: flex; flex-direction: column; overflow: hidden; }
.fab.hidden { display: none; }

.modal-error {
  background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.35);
  color: var(--danger); border-radius: 7px; padding: .5rem .85rem;
  font-size: .85rem; margin-bottom: .75rem;
}

.suggestions { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .4rem; }
.suggestion-item {
  padding: .2rem .65rem; border-radius: 20px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text-sec); font-size: .78rem; font-family: inherit;
  cursor: pointer; transition: all .12s; white-space: nowrap;
}
.suggestion-item:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

/* ── Touch devices (phones & tablets): always-visible actions, content at bottom ── */
@media (hover: none) {
  .link-card { min-height: 120px; }
  .link-card-body { margin-top: auto; }
  .link-card .link-actions { display: flex; }
  .link-action-btn { width: 30px; height: 30px; font-size: .9rem; }
}

@media (max-width: 600px) {
  .app-header { flex-wrap: wrap; height: auto; padding: .65rem 1rem; gap: .4rem; }
  .app-logo { flex: 1; }
  .search-section { order: 3; flex-basis: 100%; max-width: 100%; }
  .links-grid { grid-template-columns: 1fr 1fr; }
  .app-main { margin-top: 170px; }
  .main-nav { top: 116px; }
}
