/* Verwaltungsbereich (/admin) */

.admin {
    max-width: 1240px;
    margin: 0 auto 40px;
    background: #f4f4f2;
    min-height: 100vh;
    font: 14px/1.45 "Segoe UI", Tahoma, Arial, sans-serif;
    color: #2b3438;
    box-shadow: 0 0 12px rgba(0, 0, 0, .35);
}

.admin * {
    font-family: inherit;
}

.admin-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 24px;
    padding: 10px 20px;
    background: #2f3e48;
    color: #fff;
}

.admin-brand {
    color: #fff;
    font-size: 17px;
    text-decoration: none;
    font-family: "Comic Sans MS", Tahoma, Arial, sans-serif !important;
}

.admin-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    flex: 1;
}

.admin-nav a {
    color: #d7dfe5;
    text-decoration: none;
    padding: 4px 10px;
    border-radius: 3px;
}

.admin-nav a:hover,
.admin-nav a.active {
    background: #4a6a80;
    color: #fff;
}

.admin-logout button {
    background: none;
    border: 1px solid #8aa4a8;
    color: #fff;
    padding: 3px 10px;
    border-radius: 3px;
    cursor: pointer;
}

.admin-main {
    padding: 16px 20px;
}

.admin h1 {
    font-size: 22px;
    margin: 4px 0 12px;
    color: #344550;
}

.admin h2 {
    font-size: 17px;
    margin: 0 0 8px;
    color: #344550;
}

.admin a {
    color: #2b7a9b;
}

.admin-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.admin-toolbar h1 {
    margin: 0 12px 0 0;
}

.admin input[type=text],
.admin input[type=search],
.admin input[type=password],
.admin input[type=date],
.admin input:not([type]),
.admin select,
.admin textarea {
    padding: 5px 7px;
    border: 1px solid #c4cbcf;
    border-radius: 3px;
    background: #fff;
    font-size: 14px;
    box-sizing: border-box;
}

.admin-toolbar input[type=search] {
    min-width: 240px;
}

.admin .btn {
    display: inline-block;
    font-size: 14px;
    text-decoration: none;
    line-height: 1.4;
    color: #fff;
}

.admin .btn.secondary {
    color: #3b5566;
}

.admin .btn.small {
    font-size: 13px;
    padding: 3px 10px;
}

.admin .btn[disabled] {
    opacity: .5;
}

.icon-btn {
    background: none;
    border: 0;
    cursor: pointer;
    font-size: 15px;
    color: #7a8589;
    padding: 2px 4px;
}

.icon-btn:hover {
    color: #b00020;
}

.icon-btn[disabled] {
    opacity: .3;
    cursor: default;
}

/* Tabellen */
.admin-grid {
    overflow-x: auto;
    background: #fff;
    border: 1px solid #dde2e4;
}

.admin .grid,
.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin .grid th,
.admin-table th {
    text-align: left;
    padding: 8px;
    font-weight: 600;
    color: #2b7a9b;
    border-bottom: 2px solid #c4cbcf;
    white-space: nowrap;
    font-size: 13px;
}

.admin .grid th .col-title {
    font-weight: 600;
}

.admin .grid td,
.admin-table td {
    padding: 5px 8px;
    border-bottom: 1px solid #eceff0;
    vertical-align: middle;
    font-size: 14px;
    white-space: nowrap;
}

.admin .grid tbody tr:nth-child(even) {
    background: #f7f8f8;
}

.admin .grid tbody tr:hover {
    background: #eef4f7;
}

.admin .grid .col-img img {
    width: 48px;
    height: 40px;
    object-fit: cover;
    display: block;
}

.admin .grid .col-flag {
    text-align: center;
}

.flag.yes { color: #2e7d32; }
.flag.no { color: #b9c0c3; }

.admin-paginator {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

.admin-paginator .paginator {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Reiter */
.admin-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid #c4cbcf;
    margin-bottom: 16px;
}

.admin-tabs button {
    padding: 8px 16px;
    border: 1px solid #c4cbcf;
    border-bottom: 0;
    background: #e6e9ea;
    border-radius: 4px 4px 0 0;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: -1px;
}

.admin-tabs button.active {
    background: #fff;
}

.admin-tabs button[disabled] {
    color: #aaa;
    cursor: default;
}

/* Formulare */
.admin-form {
    background: #fff;
    border: 1px solid #dde2e4;
    padding: 16px 20px;
}

.admin-form.narrow {
    max-width: 560px;
}

.form-row {
    display: grid;
    grid-template-columns: 160px minmax(0, 1fr);
    gap: 6px 16px;
    align-items: start;
    margin-bottom: 10px;
}

.form-row > label {
    text-align: right;
    padding-top: 6px;
    font-weight: 600;
}

.form-row input:not([type=checkbox]):not([type=radio]),
.form-row select {
    width: 100%;
    max-width: 520px;
}

.form-row input.short:not([type=checkbox]):not([type=radio]) {
    max-width: 160px;
}

.form-row small {
    color: #6b7579;
    margin-left: 8px;
}

label.inline {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin: 4px 16px 4px 0;
    font-weight: normal;
}

.checks,
.kitten-list {
    padding-top: 4px;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
}

.hint {
    color: #5c676b;
    font-size: 13px;
    margin: 12px 0;
    max-width: 800px;
}

.muted {
    color: #7a8589;
    font-size: 13px;
}

.save-ok {
    color: #2e7d32;
}

.validation-errors {
    color: #b00020;
    margin: 0 0 12px 20px;
}

.file-btn {
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.file-btn input[type=file] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* Galerie-Pflege */
.drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 90px;
    margin-bottom: 12px;
    padding: 16px;
    border: 2px dashed #9fb1bc;
    border-radius: 6px;
    background: #f7f9fa;
    color: #3b5566;
    text-align: center;
    transition: background .15s, border-color .15s;
}

.drop-zone:hover,
.drop-zone.over {
    border-color: #2b7a9b;
    background: #eaf3f7;
}

.drop-zone.busy {
    cursor: progress;
}

.drop-zone progress {
    width: min(320px, 100%);
}

.gallery-status {
    margin: -4px 0 8px;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.gallery-tile {
    position: relative;
    background: #fff;
    border: 1px solid #dde2e4;
    border-radius: 4px;
    overflow: hidden;
    cursor: grab;
    transition: box-shadow .15s, opacity .15s;
}

.gallery-tile:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
}

.gallery-tile.dragging {
    opacity: .4;
}

.gallery-tile.drop-before {
    box-shadow: -4px 0 0 #2b7a9b;
}

.gallery-tile.drop-after {
    box-shadow: 4px 0 0 #2b7a9b;
}

.gallery-thumb {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: #f1f1ef;
    cursor: pointer;
}

.gallery-thumb img {
    display: block;
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
}

.tile-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    padding: 1px 6px;
    border-radius: 3px;
    background: #2b7a9b;
    color: #fff;
    font-size: 11px;
    pointer-events: none;
}

.tile-actions {
    position: absolute;
    top: 6px;
    right: 6px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity .15s;
}

.gallery-tile:hover .tile-actions,
.gallery-tile:focus-within .tile-actions {
    opacity: 1;
}

.tile-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .92);
    color: #3b5566;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}

.tile-btn:hover {
    background: #fff;
    color: #2b7a9b;
}

.tile-btn.danger:hover {
    color: #b3261e;
}

.tile-btn svg,
.tile-info svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tile-caption {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    font-size: 13px;
    min-height: 20px;
}

.tile-no {
    font-weight: 600;
    color: #6b7c87;
}

.tile-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tile-info {
    display: flex;
    color: #6b7c87;
}

/* Dialog */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(20, 28, 34, .55);
}

.modal {
    position: fixed;
    z-index: 1001;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    width: min(980px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .35);
}

.modal-header,
.modal-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
}

.modal-header {
    border-bottom: 1px solid #e4e8ea;
}

.modal-header h2 {
    flex: 1;
    margin: 0;
    font-size: 18px;
}

.modal-close {
    border: 0;
    background: none;
    font-size: 26px;
    line-height: 1;
    color: #6b7c87;
    cursor: pointer;
}

.modal-body {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
    gap: 16px;
    padding: 16px;
    overflow: auto;
}

.modal-footer {
    border-top: 1px solid #e4e8ea;
}

.modal-footer .muted {
    flex: 1;
}

.gallery-dialog-image {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    background: #f1f1ef;
}

.gallery-dialog-image img {
    max-width: 100%;
    max-height: calc(100vh - 220px);
    object-fit: contain;
}

.gallery-dialog-image .nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .9);
    font-size: 26px;
    line-height: 1;
    color: #3b5566;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
}

.gallery-dialog-image .nav[disabled] {
    opacity: .3;
    cursor: default;
}

.gallery-dialog-image .prev {
    left: 8px;
}

.gallery-dialog-image .next {
    right: 8px;
}

.gallery-dialog-fields {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.gallery-dialog-fields label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-weight: 600;
}

.gallery-dialog-fields input,
.gallery-dialog-fields textarea {
    width: 100%;
    font-weight: normal;
}

.gallery-dialog-meta {
    font-size: 12px;
    word-break: break-all;
}

.gallery-dialog-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.gallery-dialog-move {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.profile-note {
    color: #2e7d32;
    font-weight: 600;
}

.admin .btn.danger {
    background: #fff;
    color: #b3261e;
    border-color: #d9a29d;
}

@media (max-width: 700px) {
    .modal-body {
        grid-template-columns: 1fr;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    }

    .tile-actions {
        opacity: 1;
    }
}

.admin-section {
    background: #fff;
    border: 1px solid #dde2e4;
    padding: 12px 16px;
    margin-bottom: 16px;
}

.admin-table input,
.admin-table select {
    width: 100%;
}

.admin-table input.short {
    max-width: 140px;
}

@media (max-width: 700px) {
    .admin-main {
        padding: 10px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .form-row > label {
        text-align: left;
        padding-top: 0;
    }
}

/* Einseitige Bearbeitung (Tier / Wurf) */
.edit-header {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin: -16px -20px 16px;
    padding: 10px 20px;
    background: #fff;
    border-bottom: 1px solid #dde2e4;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .06);
}

.edit-header h1 {
    margin: 0;
    font-size: 20px;
}

.edit-jump {
    display: flex;
    gap: 2px;
    flex: 1;
}

.edit-jump button {
    padding: 4px 10px;
    border: 0;
    border-radius: 3px;
    background: none;
    color: #2b7a9b;
    cursor: pointer;
}

.edit-jump button:hover {
    background: #eaf3f7;
}

.edit-state {
    min-width: 110px;
    text-align: right;
}

.dirty-note {
    color: #b06a3b;
    font-weight: 600;
}

.edit-section {
    scroll-margin-top: 70px;
    margin-bottom: 16px;
    padding: 16px 20px;
    background: #fff;
    border: 1px solid #dde2e4;
}

.edit-section > h2 {
    margin: 0 0 14px;
    padding-bottom: 6px;
    border-bottom: 1px solid #e8ecee;
}

.edit-columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0 32px;
}

.edit-columns .form-row {
    grid-template-columns: 110px minmax(0, 1fr);
}

.edit-flags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 24px;
    margin: 6px 0 0;
    padding: 12px 0 0;
    border-top: 1px solid #e8ecee;
}

/* Merkmale als Schalter */
label.switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

label.switch input[type=checkbox] {
    appearance: none;
    position: relative;
    width: 34px;
    height: 18px;
    margin: 0;
    border-radius: 9px;
    background: #c3ccd1;
    cursor: pointer;
    transition: background .2s;
}

label.switch input[type=checkbox]::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    transition: transform .2s;
}

label.switch input[type=checkbox]:checked {
    background: #2b7a9b;
}

label.switch input[type=checkbox]:checked::after {
    transform: translateX(16px);
}

label.switch input[type=checkbox]:focus-visible {
    outline: 2px solid #2b7a9b;
    outline-offset: 2px;
}

.edit-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 14px;
}

.edit-field > label {
    font-weight: 600;
}

.edit-field textarea {
    width: 100%;
    box-sizing: border-box;
}

.gallery-note {
    margin-top: 0;
}

@media (max-width: 900px) {
    .edit-columns {
        grid-template-columns: 1fr;
    }

    .edit-header {
        margin: -16px -12px 12px;
        padding: 8px 12px;
    }

    .edit-jump {
        order: 5;
        flex-basis: 100%;
    }

    .edit-state {
        min-width: 0;
    }
}

@media (max-width: 600px) {
    .edit-columns .form-row,
    .form-row {
        grid-template-columns: 1fr;
    }

    .form-row > label {
        text-align: left;
        padding-top: 0;
    }

    .edit-section {
        padding: 12px;
        scroll-margin-top: 90px;
    }

    /* Kopfzeile kompakt: Name in einer Zeile, darunter die Buttons; Sprunglinks entfallen */
    .edit-header h1 {
        flex-basis: 100%;
        font-size: 17px;
    }

    .edit-jump {
        display: none;
    }

    .edit-header .btn {
        padding: 4px 10px;
        font-size: 13px;
    }

    .edit-state {
        order: 6;
        flex-basis: 100%;
        text-align: left;
    }

    .edit-state:empty {
        display: none;
    }
}

/* Profilbild in der Galerie */
.gallery-tile.is-profile,
.gallery-tile.profile-only {
    border: 2px solid #2b7a9b;
}

.gallery-tile.profile-only {
    border-style: dashed;
    cursor: default;
}

.link-btn {
    padding: 0;
    border: 0;
    background: none;
    color: #2b7a9b;
    text-decoration: underline;
    cursor: pointer;
    font-size: 13px;
}

.link-btn[disabled] {
    opacity: .5;
    cursor: default;
}

/* Bildbearbeitung im Galerie-Dialog */
.image-tools {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    padding: 10px 12px 12px;
    border: 1px solid #dde2e4;
    border-radius: 4px;
}

.image-tools legend {
    padding: 0 4px;
    font-weight: 600;
}

.image-tools-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.gallery-dialog-fields label.slider {
    display: grid;
    grid-template-columns: 95px minmax(0, 1fr) 48px;
    align-items: center;
    gap: 8px;
    font-weight: normal;
}

.slider input[type=range] {
    width: 100%;
}

.slider output {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: #5c676b;
}

.gallery-dialog-image {
    overflow: hidden;
}

.gallery-dialog-image img {
    transition: transform .2s;
}

/* gedrehte Vorschau muss auch hochkant in den Rahmen passen */
.gallery-dialog-image.rotated img {
    max-width: min(100%, calc(100vh - 220px));
    max-height: min(520px, calc(100vh - 220px));
}

.gallery-dialog-move {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
