/* =========================================================
   TGP-Galerie – Stylesheet (Frontend + Admin)
   ========================================================= */
:root {
    --bg: #0f1115;
    --surface: #1a1d24;
    --surface-2: #232730;
    --text: #e8eaed;
    --muted: #9aa0aa;
    --accent: #4f8cff;
    --accent-2: #2f6fe0;
    --danger: #e0533d;
    --border: #2c313c;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

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

.container { max-width: 1200px; margin: 0 auto; padding: 24px 16px 64px; }

/* ---- Kopf / Fuss ---- */
.site-header {
    padding: 14px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.brand { font-size: 1.25rem; font-weight: 700; color: var(--text); }
.head-tools { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.head-search { display: flex; }
.head-search input {
    background: var(--surface-2); border: 1px solid var(--border); border-right: none;
    color: var(--text); padding: 7px 12px; border-radius: 8px 0 0 8px; font-size: .9rem; min-width: 160px;
}
.head-search button {
    background: var(--accent); color: #fff; border: 1px solid var(--accent);
    border-radius: 0 8px 8px 0; padding: 0 12px; cursor: pointer; font-size: 1.1rem;
}
.lang-switch { display: flex; gap: 4px; }
.lang-switch a {
    color: var(--muted); font-size: .8rem; font-weight: 600; padding: 4px 7px;
    border: 1px solid var(--border); border-radius: 6px;
}
.lang-switch a:hover { color: var(--text); text-decoration: none; border-color: var(--accent); }
.lang-switch a.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Tags */
.taglist { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 20px; }
.tag {
    background: var(--surface); border: 1px solid var(--border); color: var(--muted);
    padding: 4px 11px; border-radius: 999px; font-size: .85rem;
}
.tag:hover { color: #fff; background: var(--accent); border-color: var(--accent); text-decoration: none; }

/* Suchformular */
.search-form { display: flex; gap: 10px; margin: 0 0 24px; max-width: 520px; }
.search-form input {
    flex: 1; background: var(--surface-2); border: 1px solid var(--border);
    color: var(--text); padding: 10px 14px; border-radius: 8px; font-size: 1rem;
}

/* Tag-Wolke */
.section-title { font-size: 1.1rem; margin: 32px 0 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.cloud-section { border-top: 1px solid var(--border); margin-top: 32px; }
.tagcloud { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; line-height: 1.8; }
.tagcloud .tag { border: none; background: none; padding: 0; color: var(--accent); }
.tagcloud .tag:hover { color: var(--text); background: none; text-decoration: underline; }
.taglist-label { color: var(--muted); font-size: .85rem; margin-right: 4px; }
.taglist-view { margin-top: 18px; align-items: center; }

/* Partner-Toplist */
.toplist { border-top: 1px solid var(--border); margin-top: 32px; }
.toplist-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.toplist-item {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 10px; color: var(--text); text-align: center; font-size: .9rem;
}
.toplist-item:hover { border-color: var(--accent); text-decoration: none; }
.toplist-item img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 6px; }

/* Werbezonen */
.adzone { margin: 18px 0; text-align: center; min-height: 0; }
.adzone:empty { display: none; }
.ad-banner img { max-width: 100%; height: auto; border-radius: 6px; }

/* Meldung / Report */
.flash-ok {
    background: #16361f; color: #9be0ac; border: 1px solid #1f5130;
    padding: 10px 14px; border-radius: 8px; margin: 0 0 16px;
}
.report-box { margin: 24px 0 8px; border-top: 1px solid var(--border); padding-top: 14px; }
.report-toggle { cursor: pointer; color: var(--muted); font-size: .9rem; list-style: none; }
.report-toggle:hover { color: var(--text); }
.report-form { max-width: 480px; margin-top: 12px; display: flex; flex-direction: column; gap: 4px; }
.report-form label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 8px; }
.report-form select, .report-form textarea, .report-form input[type=email] {
    width: 100%; margin-top: 4px; padding: 9px 12px; background: var(--surface-2);
    color: var(--text); border: 1px solid var(--border); border-radius: 8px; font-size: .92rem; font-family: inherit;
}
.report-form .btn { align-self: flex-start; }
.report-form .hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Admin: Auswahl-Checkbox auf Thumbnails */
.sel-check { position: absolute; top: 6px; left: 6px; z-index: 3; }
.sel-check input { width: 20px; height: 20px; cursor: pointer; }
.toolbar-buttons { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar-buttons form { margin: 0; }
label.inline { display: inline-flex; align-items: center; gap: 6px; margin-right: 16px; }
label.inline input { width: auto; margin: 0; }
.design-form select, .form-stacked select { display: block; width: 100%; margin-top: 5px; padding: 10px 12px; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; }
.site-footer {
    text-align: center;
    color: var(--muted);
    padding: 28px 16px;
    border-top: 1px solid var(--border);
    font-size: .9rem;
}
.page-title { margin: 8px 0 24px; font-size: 1.6rem; }

/* ---- Raster ---- */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}
.grid.thumbs { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }

.card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform .12s ease, border-color .12s ease;
    color: var(--text);
}
.card:hover { transform: translateY(-3px); border-color: var(--accent); text-decoration: none; }

.card-thumb {
    aspect-ratio: 1 / 1;
    background: var(--surface-2);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.noimg, .noimg-sm { color: var(--muted); font-size: .85rem; }

.card-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.card-title { font-weight: 600; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-count { color: var(--muted); font-size: .8rem; }

/* ---- Breadcrumb / Beschreibung ---- */
.breadcrumb { color: var(--muted); font-size: .9rem; margin-bottom: 8px; }
.breadcrumb span { color: var(--text); }
.gallery-desc { color: var(--muted); margin: 0 0 20px; }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }

/* ---- Einzelbild-Viewer ---- */
.viewer {
    position: relative;
    display: flex; align-items: center; justify-content: center;
    gap: 8px;
    margin: 8px 0 16px;
}
.viewer-stage {
    flex: 1;
    display: flex; align-items: center; justify-content: center;
    max-height: 80vh;
}
.viewer-stage img {
    max-width: 100%;
    max-height: 80vh;
    border-radius: var(--radius);
    box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
.viewer-nav {
    flex: 0 0 auto;
    font-size: 2.4rem; line-height: 1;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 54px; height: 54px;
    display: flex; align-items: center; justify-content: center;
}
.viewer-nav:hover { background: var(--accent); text-decoration: none; }
.viewer-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---- Buttons ---- */
.btn {
    display: inline-block;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 16px;
    font-size: .95rem;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-secondary { background: transparent; }
.btn-danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.btn-small { padding: 5px 10px; font-size: .8rem; }
.btn[disabled] { opacity: .5; cursor: default; }

/* ---- Pagination ---- */
.pagination { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 28px 0 8px; }
.pg {
    min-width: 38px; text-align: center;
    padding: 7px 10px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    color: var(--text);
}
.pg:hover { border-color: var(--accent); text-decoration: none; }
.pg.current { background: var(--accent); border-color: var(--accent); color: #fff; }
.pg.dots { border: none; background: none; }
.pagination-info { text-align: center; color: var(--muted); font-size: .85rem; }

/* ---- Age-Gate ---- */
.agegate-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.agegate {
    max-width: 460px; text-align: center;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 32px 28px;
}
.agegate h1 { margin-top: 0; }
.agegate-form { display: flex; flex-direction: column; gap: 12px; margin: 22px 0 12px; }
.agegate-note { color: var(--muted); font-size: .8rem; }

/* =========================================================
   ADMIN
   ========================================================= */
body.admin { background: #0d0f13; }
.admin-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 22px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.admin-brand { font-weight: 700; }
.admin-nav a { margin-left: 16px; color: var(--muted); }
.admin-nav a:hover { color: var(--text); }
.admin-main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }
.admin-footer { text-align: center; color: var(--muted); padding: 24px; }

.login-box { max-width: 360px; margin: 8vh auto 0; background: var(--surface); padding: 28px; border: 1px solid var(--border); border-radius: var(--radius); }
.login-box h1 { margin-top: 0; }

.msg { padding: 10px 14px; border-radius: 8px; margin: 0 0 18px; }
.msg.ok { background: #16361f; color: #9be0ac; border: 1px solid #1f5130; }
.msg.error { background: #3a1a16; color: #f0a99c; border: 1px solid #5a241d; }

label { display: block; margin-bottom: 14px; font-size: .9rem; color: var(--muted); }
input[type=text], input[type=password], textarea, input[type=file] {
    display: block; width: 100%; margin-top: 5px;
    padding: 10px 12px; background: var(--surface-2); color: var(--text);
    border: 1px solid var(--border); border-radius: 8px; font-size: .95rem;
}
textarea { resize: vertical; }

.form-inline { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.form-inline label { flex: 1; min-width: 180px; margin-bottom: 0; }
.form-stacked { max-width: 600px; }

.admin-create, .admin-upload, .admin-meta, .admin-list, .admin-images {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px 22px; margin-bottom: 22px;
}
.hint { color: var(--muted); font-size: .82rem; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 600; font-size: .85rem; }
.t-thumb img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; }
.t-actions { display: flex; gap: 8px; align-items: center; }
.t-actions form { margin: 0; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; font-size: .85em; }

.admin-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.acard { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.acard.is-cover { border-color: var(--accent); }
.acard-thumb { position: relative; aspect-ratio: 1/1; background: #000; }
.acard-thumb img { width: 100%; height: 100%; object-fit: cover; }
.badge { position: absolute; top: 6px; left: 6px; background: var(--accent); color: #fff; font-size: .7rem; padding: 2px 7px; border-radius: 5px; }
.acard-actions { display: flex; gap: 6px; padding: 8px; }
.acard-actions form { margin: 0; flex: 1; }
.acard-actions .btn { width: 100%; }

/* ---- Sortier-Leiste (Index) ---- */
.sortbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 20px; }
.sort-tab {
    padding: 7px 14px; border-radius: 999px;
    background: var(--surface); border: 1px solid var(--border); color: var(--muted);
}
.sort-tab:hover { color: var(--text); text-decoration: none; border-color: var(--accent); }
.sort-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.site-intro { color: var(--muted); margin: -8px 0 20px; }

/* ---- Theme-Bausteine ---- */
.theme-header, .theme-footer { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.theme-header { padding-top: 16px; }
.theme-footer { padding-bottom: 8px; color: var(--muted); }

/* ---- Design-Editor ---- */
.design-form fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 18px; }
.design-form legend { padding: 0 8px; color: var(--accent); font-weight: 600; }
textarea.code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .85rem; line-height: 1.45; }

/* ---- Drag & Drop Bildsortierung ---- */
.order-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.order-toolbar .hint { margin: 0; flex: 1; min-width: 220px; }
.order-toolbar form { margin: 0; }
.sortable .acard { cursor: grab; }
.sortable .acard.dragging { opacity: .4; outline: 2px dashed var(--accent); }
.drag-handle { position: absolute; top: 6px; right: 8px; color: #fff; background: rgba(0,0,0,.45); border-radius: 5px; padding: 0 6px; font-size: .9rem; cursor: grab; z-index: 2; }
.pos { position: absolute; bottom: 6px; right: 8px; background: rgba(0,0,0,.6); color: #fff; font-size: .72rem; padding: 1px 7px; border-radius: 5px; }

@media (max-width: 600px) {
    .form-inline { flex-direction: column; align-items: stretch; }
    .viewer-nav { width: 44px; height: 44px; font-size: 1.8rem; }
}
