/* Schildkroeten-Doku — Clean Modern Theme */

:root {
    --primary: #0f766e;
    --primary-dark: #0d5c56;
    --primary-light: #14b8a6;
    --primary-pale: #ccfbf1;
    --surface: #f8fafc;
    --surface-card: #ffffff;
    --surface-hover: #f1f5f9;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --accent: #6366f1;
    --accent-light: #e0e7ff;
    --amber: #f59e0b;
    --red-warn: #ef4444;
    --red-glow: rgba(239, 68, 68, 0.25);
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.04), 0 2px 4px rgba(0,0,0,0.03);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.04);
    --radius: 14px;
    --radius-sm: 10px;
}

* {
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--surface);
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 0.92rem;
    color: var(--text);
}

/* ========== Navbar ========== */
.bg-dark-green {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0f766e 100%) !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

.navbar {
    padding: 0.45rem 0.75rem;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
}

.navbar .btn-outline-light {
    border-color: rgba(255,255,255,0.2);
    font-size: 0.78rem;
    border-radius: 8px;
    font-weight: 500;
    transition: background-color 0.2s, border-color 0.2s;
}

.navbar .btn-outline-light:hover {
    background-color: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.4);
}

/* ========== Dashboard ========== */
#dashboardList {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-start;
}

.dash-item {
    border-radius: var(--radius);
}

/* Sektions-Überschriften */
.section-header {
    flex: 0 0 100%;
    padding: 0;
    margin-top: 6px;
    border-bottom: none;
    position: relative;
}

.section-header:first-child {
    margin-top: 0;
}

.section-header > .d-flex {
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    -webkit-background-clip: padding-box, border-box;
    background-origin: padding-box, border-box;
    background-clip: padding-box, border-box;
    background-image:
        linear-gradient(var(--surface-card), var(--surface-card)),
        linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0f766e 100%);
    padding: 6px 12px;
}

.section-title {
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    outline: none;
    cursor: text;
    padding: 2px 4px;
    border-radius: 4px;
    transition: background-color 0.15s;
}

.section-title:focus {
    background: var(--border-light);
    color: var(--text);
}

.section-collapse-btn i {
    transition: transform 0.2s ease;
    display: inline-block;
}

.section-move-btn:hover {
    opacity: 0.8;
}

/* Native browser X-Button bei type="search" ausblenden (Custom X bleibt) */
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
}

/* Turtle Tiles */
.turtle-tile {
    flex: 0 0 calc(33.33% - 8px);
    min-width: 200px;
    position: relative;
}

.sortable-ghost {
    opacity: 0.2;
    background: var(--primary-pale) !important;
    border-radius: var(--radius);
    transform: scale(0.96);
}

.sortable-drag,
.sortable-fallback {
    box-shadow: var(--shadow-lg) !important;
    transform: rotate(1deg);
    opacity: 0.9;
}

/* ========== Turtle Tile ========== */
.tile-link {
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden;
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    color: inherit;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    box-shadow: var(--shadow-xs);
    -webkit-user-select: none;
    user-select: none;
}

.tile-link:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
    color: inherit;
}

.tile-link:active {
    transform: translateY(0) scale(0.99);
    box-shadow: var(--shadow-xs);
}

.tile-content {
    position: relative;
    z-index: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Zeile 1: Name */
.tile-row-name {
    display: flex;
    align-items: center;
}

.tile-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -0.01em;
}

.tile-kennz {
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: -1px;
}

/* Zeile 2: Info + Badges */
.tile-row-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.tile-info {
    display: flex;
    gap: 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    min-width: 0;
}

.tile-info i {
    font-size: 0.68rem;
    opacity: 0.6;
}

.tile-hinweis {
    overflow: hidden;
    text-overflow: ellipsis;
}

.tile-badges {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

/* Badges */
.tile-link .badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
    letter-spacing: 0.01em;
}

.tile-link .badge.bg-success {
    background: var(--primary) !important;
}

.tile-link .badge.bg-danger {
    background: var(--red-warn) !important;
}

.tile-link .badge.bg-secondary {
    background: var(--text-muted) !important;
}

.tile-link .badge.bg-dark {
    background: #475569 !important;
}

/* Inaktive Tiere */
.inactive-turtle .tile-link {
    opacity: 0.4;
    filter: grayscale(20%);
}

.inactive-turtle .tile-link:hover {
    opacity: 0.65;
    filter: grayscale(0%);
}

/* Sparkline im Hintergrund */
.sparkline-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.5;
}

/* ========== Doku-Fälligkeit: Roter Glow ========== */
.doku-faellig {
    border-color: var(--red-warn) !important;
    box-shadow: 0 0 0 1px var(--red-warn), 0 0 12px var(--red-glow);
    animation: dokuPulse 2.8s ease-in-out infinite;
}

@keyframes dokuPulse {
    0%, 100% { box-shadow: 0 0 0 1px var(--red-warn), 0 0 8px var(--red-glow); }
    50% { box-shadow: 0 0 0 1px var(--red-warn), 0 0 20px var(--red-glow); }
}

.doku-faellig:hover {
    border-color: var(--red-warn) !important;
    transform: translateY(-2px);
}

/* ========== Cards (Detail-Seiten) ========== */
.card {
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    background: var(--surface-card);
    border-bottom: 1px solid var(--border);
    padding: 0.65rem 0.9rem;
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text);
}

/* Buttons */
.btn-success {
    background: var(--primary);
    border: none;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: background-color 0.2s, box-shadow 0.2s, transform 0.15s;
}

.btn-success:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(15, 118, 110, 0.3);
    transform: translateY(-1px);
}

.btn-success:active {
    transform: translateY(0);
    background: var(--primary-dark);
}

/* ========== Dokumentation Page ========== */
.foto-preview {
    max-width: 100%;
    max-height: 250px;
    object-fit: contain;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.foto-upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s;
    background: var(--surface);
}

.foto-upload-area:hover {
    border-color: var(--primary-light);
    background-color: var(--primary-pale);
}

.foto-upload-area i {
    font-size: 2rem;
    color: var(--primary);
}

.cropper-container {
    max-height: 60vh;
}

.crop-toolbar {
    display: flex;
    gap: 0.35rem;
}

.crop-toolbar .btn {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: var(--radius-sm);
}

/* ========== Avatars (Detail) ========== */
.turtle-avatar {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary-pale);
    box-shadow: var(--shadow-sm);
}

.turtle-avatar-placeholder {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-pale) 0%, #a7f3d0 100%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: var(--primary-dark);
    box-shadow: var(--shadow-sm);
}

/* ========== Detail Page ========== */
.detail-header {
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
}

.detail-name {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

.detail-kennz {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 1px;
    display: block;
}

.btn-back {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s, border-color 0.15s;
}

.btn-back:hover {
    background: var(--border-light);
    border-color: var(--primary-light);
    color: var(--primary);
}

.btn-edit {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s, border-color 0.15s;
}

.btn-edit:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

.status-pill {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.status-aktiv {
    background: var(--primary-pale);
    color: var(--primary-dark);
}

.status-abgegeben {
    background: #f1f5f9;
    color: var(--text-muted);
}

.status-verstorben {
    background: #f1f5f9;
    color: #475569;
}

/* Detail Cards */
.detail-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.detail-card-header {
    background: var(--surface-card);
    border-bottom: 1px solid var(--border);
    padding: 0.6rem 0.9rem;
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.detail-card-header i {
    color: var(--primary);
    font-size: 0.9rem;
}

/* Stammdaten Grid */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

.detail-field {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-light);
}

.detail-field:nth-child(odd) {
    border-right: 1px solid var(--border-light);
}

.detail-field-wide {
    grid-column: 1 / -1;
    border-right: none !important;
}

.detail-label {
    display: block;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.detail-value {
    font-size: 0.88rem;
    color: var(--text);
    font-weight: 500;
}

/* Doku Button */
.btn-doku {
    border-radius: var(--radius);
    font-weight: 600;
    letter-spacing: 0.01em;
    padding: 0.85rem;
}

/* Measurement Items (editierbar) */
.measurement-item {
    border-bottom: 1px solid var(--border-light);
    transition: background-color 0.15s;
}

.measurement-item:last-child {
    border-bottom: none;
}

.measurement-item.editing {
    background: var(--surface);
}

.measurement-display {
    padding: 10px 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.15s;
    position: relative;
}

.measurement-display:hover {
    background: var(--surface-hover);
}

.measurement-main {
    flex-grow: 1;
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.measurement-weight {
    font-size: 0.9rem;
    color: var(--text);
}

.measurement-date {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.measurement-note {
    font-size: 0.75rem;
    color: var(--text-secondary);
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.measurement-chevron {
    color: var(--text-muted);
    font-size: 0.7rem;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.measurement-item.editing .measurement-chevron {
    transform: rotate(180deg);
}

.measurement-edit {
    padding: 0 14px 12px;
    border-top: 1px solid var(--border-light);
}

/* Fotodoku Items */
.photodoc-item {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-light);
}

.photodoc-item:last-child {
    border-bottom: none;
}

.photodoc-thumbs {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.photodoc-thumb {
    width: calc(50% - 4px);
    aspect-ratio: 4/3;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

/* ========== Settings ========== */
.settings-table th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    padding: 8px 10px;
}

.settings-table td {
    padding: 6px 10px;
    vertical-align: middle;
}

.settings-table .form-control-sm {
    font-size: 0.82rem;
}

/* ========== Autocomplete Dropdown ========== */
.autocomplete-dropdown {
    display: none;
    position: absolute;
    left: 12px;
    right: 12px;
    z-index: 1050;
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    max-height: 200px;
    overflow-y: auto;
}

.autocomplete-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--border-light);
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover {
    background: var(--surface-hover);
}

/* ========== Export Doku-Dates Checkboxen ========== */
.doku-year-group {
    padding: 6px 0;
}

.doku-year-label {
    font-weight: 700;
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.doku-date-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
}

.doku-date-check {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.82rem;
    color: var(--text);
    cursor: pointer;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border-light);
    transition: background-color 0.15s, border-color 0.15s;
}

.doku-date-check:hover {
    background: var(--primary-pale);
    border-color: var(--primary-light);
}

.doku-date-check input[type="checkbox"] {
    accent-color: var(--primary);
    margin: 0;
}

/* ========== Collapse Toggle ========== */
.collapse-toggle {
    cursor: pointer;
    user-select: none;
}

.collapse-toggle:hover {
    background: var(--surface-hover);
}

.collapse-chevron {
    transition: transform 0.25s ease;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.collapse-toggle:not(.collapsed) .collapse-chevron {
    transform: rotate(180deg);
}

/* ========== Alerts ========== */
.alert {
    border-radius: var(--radius-sm);
    border: none;
    box-shadow: var(--shadow-xs);
}

/* ========== Forms ========== */
.form-control:focus, .form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15);
}

/* ========== Responsive ========== */

/* Tablet: 2 Spalten */
@media (max-width: 768px) {
    .turtle-tile {
        flex: 0 0 calc(50% - 6px);
        min-width: 160px;
    }
}

/* Handy: 2 Spalten eng */
@media (max-width: 576px) {
    .container-fluid {
        padding-left: 10px;
        padding-right: 10px;
    }

    h4 { font-size: 1.1rem; }

    .btn-lg {
        font-size: 1.1rem;
        padding: 0.75rem;
    }

    .turtle-tile {
        flex: 0 0 calc(50% - 5px);
        min-width: 140px;
    }

    .tile-link {
        padding: 10px 10px;
    }

    .tile-name {
        font-size: 0.88rem;
    }

    .tile-info {
        font-size: 0.68rem;
        flex-direction: column;
        gap: 1px;
    }

    #dashboardList {
        gap: 8px;
    }
}

/* ========== Dark Mode ========== */
[data-bs-theme="dark"] {
    --primary: #14b8a6;
    --primary-dark: #0d9488;
    --primary-light: #2dd4bf;
    --primary-pale: rgba(20, 184, 166, 0.15);
    --surface: #0f172a;
    --surface-card: #1e293b;
    --surface-hover: #334155;
    --border: #334155;
    --border-light: #1e293b;
    --text: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #818cf8;
    --accent-light: rgba(129, 140, 248, 0.15);
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.2);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.4), 0 4px 10px rgba(0,0,0,0.3);
}

[data-bs-theme="dark"] .bg-dark-green {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0d5c56 100%) !important;
}

[data-bs-theme="dark"] .status-abgegeben,
[data-bs-theme="dark"] .status-verstorben {
    background: #334155;
    color: #94a3b8;
}

[data-bs-theme="dark"] .tile-link .badge.bg-dark {
    background: #64748b !important;
}

[data-bs-theme="dark"] .section-header > .d-flex {
    background-image:
        linear-gradient(var(--surface-card), var(--surface-card)),
        linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0d5c56 100%);
}

[data-bs-theme="dark"] .turtle-avatar-placeholder {
    background: linear-gradient(135deg, rgba(20, 184, 166, 0.2) 0%, rgba(16, 185, 129, 0.2) 100%);
    color: var(--primary-light);
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: var(--surface);
    border-color: var(--border);
    color: var(--text);
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.2);
}

[data-bs-theme="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text);
    --bs-table-border-color: var(--border);
}

[data-bs-theme="dark"] .btn-success:hover {
    box-shadow: 0 4px 12px rgba(20, 184, 166, 0.3);
}

/* Theme Toggle */
.theme-toggle {
    background: none;
    border: 1px solid rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.8);
    border-radius: 8px;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
    font-size: 0.85rem;
    padding: 0;
}

.theme-toggle:hover {
    background-color: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.4);
}
