/* ──────────────────────────────────────────────────────────────────────────
   Bookmark Manager – Stylesheet
   Design: dark-neutral, comfortable for long reading sessions
   ────────────────────────────────────────────────────────────────────────── */

/* ─── Variables ─────────────────────────────────────────────────────────── */
:root {
    --bg:        #111317;
    --surface:   #1c1f26;
    --surface-2: #252830;
    --border:    #2e3240;
    --text:      #dde2ec;
    --text-muted:#7c849a;
    --accent:    #4f8ef7;
    --accent-h:  #3d7ce8;
    --danger:    #e05252;
    --success:   #4caf7d;
    --tag-bg:    #1e2d4a;
    --tag-text:  #7ab3f7;
    --radius:    8px;
    --shadow:    0 2px 12px rgba(0,0,0,.35);
    --font:      system-ui, -apple-system, 'Segoe UI', sans-serif;
    --mono:      'JetBrains Mono', 'Fira Code', monospace;
}

/* ─── Reset & Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Top bar ────────────────────────────────────────────────────────────── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar-brand {
    font-size: 1.1rem;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: -.01em;
}

.topbar-search { flex: 1; max-width: 420px; }
.topbar-search input {
    width: 100%;
    padding: 0.45rem 0.8rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9rem;
}
.topbar-search input:focus { outline: none; border-color: var(--accent); }

.topbar-actions { display: flex; gap: 0.5rem; margin-left: auto; }

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.45rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, opacity .15s;
    white-space: nowrap;
}

.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); }
.btn-primary:disabled { opacity: .45; cursor: default; }

.btn-ghost    { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }

.btn-danger   { background: var(--danger); color: #fff; }

.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 0.25rem;
    border-radius: 4px;
    opacity: 0.5;
    transition: opacity .15s;
}
.btn-icon:hover { opacity: 1; }

/* ─── Layout ─────────────────────────────────────────────────────────────── */
.layout {
    display: flex;
    min-height: calc(100vh - 54px);
}

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
    width: 210px;
    flex-shrink: 0;
    padding: 1.25rem 0.75rem;
    border-right: 1px solid var(--border);
    background: var(--surface);
    overflow-y: auto;
}

.sidebar-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--text-muted);
    padding: 0 0.5rem 0.5rem;
}

#tag-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }

.tag-item {
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-muted);
    transition: background .12s, color .12s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.tag-item:hover  { background: var(--surface-2); color: var(--text); }
.tag-item.active { background: var(--tag-bg); color: var(--tag-text); font-weight: 600; }

.tag-count {
    font-size: 0.72rem;
    background: var(--border);
    padding: 0 5px;
    border-radius: 10px;
}

.sidebar-section { padding: 0.75rem 0.25rem 0; }

/* ─── Main content ───────────────────────────────────────────────────────── */
.content { flex: 1; padding: 1.5rem; overflow-y: auto; }

.bookmark-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

/* ─── Bookmark card ──────────────────────────────────────────────────────── */
.bookmark-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    display: flex;
    gap: 0.75rem;
    position: relative;
    transition: border-color .15s, box-shadow .15s;
}
.bookmark-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow);
}

.bookmark-card.dead { border-left: 3px solid var(--danger); }

.card-favicon { flex-shrink: 0; }
.card-favicon img { width: 20px; height: 20px; border-radius: 3px; margin-top: 2px; }

.card-body { flex: 1; min-width: 0; }

.card-title {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.25rem;
}
.card-title:hover { color: var(--accent); }

.card-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.card-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.5rem; }

.tag-pill {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    background: var(--tag-bg);
    color: var(--tag-text);
    border-radius: 20px;
    font-size: 0.72rem;
    cursor: pointer;
    transition: opacity .12s;
}
.tag-pill:hover { opacity: .75; }

.card-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.card-status.dead   { color: var(--danger); }
.card-status.alive  { color: var(--success); }
.card-status.pending{ color: var(--text-muted); }

.card-actions {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: none;
    gap: 0.15rem;
}
.bookmark-card:hover .card-actions { display: flex; }

/* ─── Dialog ─────────────────────────────────────────────────────────────── */
dialog {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 0;
    max-width: 480px;
    width: 90%;
    box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(0,0,0,.6); }

.dialog-inner { padding: 1.75rem; }

dialog h2 { margin-bottom: 1.25rem; font-size: 1rem; }

dialog label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

dialog input[type=text],
dialog input[type=url] {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
    width: 100%;
}
dialog input:focus { outline: none; border-color: var(--accent); }

.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.25rem; }

/* ─── Preview box (in add dialog) ───────────────────────────────────────── */
.preview-box {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
}
.preview-box img { width: 20px; height: 20px; flex-shrink: 0; }
.preview-info { min-width: 0; }
.preview-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-desc  { color: var(--text-muted); font-size: 0.8rem; margin-top: 0.15rem;
                 display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ─── States ─────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.loading-spinner {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-style: italic;
}

.alert {
    padding: 0.65rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
}
.alert-error { background: rgba(224,82,82,.15); border: 1px solid var(--danger); color: var(--danger); }

/* ─── Pagination ──────────────────────────────────────────────────────────── */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    padding: 1.5rem 0;
}
.pagination-info { color: var(--text-muted); font-size: 0.85rem; }

/* ─── Login page ──────────────────────────────────────────────────────────── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 360px;
    box-shadow: var(--shadow);
}

.login-box h1 { font-size: 1.3rem; margin-bottom: 1.5rem; text-align: center; }

.login-box label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.login-box input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
    width: 100%;
}
.login-box input:focus { outline: none; border-color: var(--accent); }

.login-box .btn { width: 100%; justify-content: center; margin-top: 0.5rem; }

/* ─── Scrollbar (webkit) ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ─── Additional styles (v2) ─────────────────────────────────────────────── */

/* Input row (URL + Vorschau-Button) */
.input-row {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}
.input-row input { flex: 1; }

/* Dialog hint text */
.dialog-hint {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    line-height: 1.5;
}

/* Preview box inside add-dialog */
.preview-box {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.65rem 0.75rem;
    display: flex;
    gap: 0.65rem;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    min-height: 44px;
}
.preview-favicon { flex-shrink: 0; padding-top: 2px; }
.preview-info    { min-width: 0; }
.preview-title   { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-desc    { color: var(--text-muted); font-size: 0.78rem; margin-top: 0.2rem;
                   display: -webkit-box; -webkit-line-clamp: 2;
                   -webkit-box-orient: vertical; overflow: hidden; }

/* File drop zone */
.file-drop {
    display: block;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.875rem;
    transition: border-color .15s, background .15s;
    margin-bottom: 0.75rem;
}
.file-drop:hover,
.file-drop.drag-over {
    border-color: var(--accent);
    background: rgba(79,142,247,.05);
    color: var(--text);
}

/* Import result */
.import-result {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.65rem 0.75rem;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
    line-height: 1.7;
}

/* Sidebar tags section title with manage button */
.sidebar-title-tags {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1rem;
}

/* Tag management dialog */
.tags-mgmt-toolbar { margin-bottom: 0.75rem; }

.tags-mgmt-list {
    max-height: 50vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 0.5rem;
}

.tag-mgmt-row {
    display: grid;
    grid-template-columns: 1fr 1fr 2rem 1.5rem 1.5rem;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    border-radius: 6px;
    font-size: 0.85rem;
}
.tag-mgmt-row:hover { background: var(--surface-2); }

.tag-mgmt-de    { font-weight: 500; }
.tag-mgmt-en    { color: var(--text-muted); }
.tag-mgmt-count {
    text-align: center;
    font-size: 0.72rem;
    background: var(--border);
    border-radius: 10px;
    padding: 0 4px;
}

/* Card status variants */
.bookmark-card.pending { border-left: 3px solid var(--text-muted); opacity: .8; }

/* Tags dialog – wider */
#tags-dialog     { max-width: 560px; }
#tags-mgmt-list  { font-size: 0.85rem; }
