/**
 * ART – Asset Recording Tool
 * Professionelles Design für Feldtechnik
 */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&display=swap');

:root {
    --bg: #f1f3f5;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --surface: #e9ecef;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-muted: #3b82f6;
    --text: #1a1d21;
    --text-2: #495057;
    --text-3: #6c757d;
    --border: #dee2e6;
    --border-focus: #2563eb;
    --danger: #dc3545;
    --success: #198754;
    --warn: #fd7e14;
    --header-bg: #1a1d21;
    --header-text: #ffffff;
    --radius: 8px;
    --radius-sm: 6px;
    --thumb-zone: 80px;
    --safe-top: env(safe-area-inset-top);
    --safe-bottom: max(env(safe-area-inset-bottom), 12px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    -webkit-tap-highlight-color: transparent;
    font-size: 15px;
    line-height: 1.5;
}

body {
    padding: var(--safe-top) 0 calc(var(--safe-bottom) + 100px);
    min-height: 100dvh;
}

.app-shell {
    max-width: 100%;
    margin: 0 auto;
    min-height: 100dvh;
    background: var(--bg);
}

/* Header – kompakt auf Handy */
.header {
    background: var(--header-bg);
    padding: 0.75rem 1rem;
    padding-top: max(0.75rem, var(--safe-top));
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header h1 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--header-text);
    letter-spacing: 0.02em;
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-actions { display: flex; gap: 0.5rem; }

.btn-icon-sm {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    color: var(--header-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-icon-sm:hover { background: rgba(255,255,255,0.18); }

/* Haupt-Navigation – mobil: scrollbar, große Touch-Ziele */
.main-nav {
    display: flex;
    gap: 6px;
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.main-nav::-webkit-scrollbar { display: none; }

.nav-tab {
    flex-shrink: 0;
    padding: 0.6rem 0.9rem;
    font-size: 0.8rem;
    font-weight: 500;
    border: none;
    background: var(--bg-input);
    color: var(--text-2);
    border-radius: 20px;
    cursor: pointer;
    min-height: 44px;
    white-space: nowrap;
}

.nav-tab.active {
    background: var(--accent);
    color: white;
}

/* Views */
.offline-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--warn);
    color: #fff;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    border-radius: var(--radius-sm);
}
.offline-banner .btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; }
.view-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 1rem; }
.view-hint { font-size: 0.9rem; color: var(--text-3); margin-bottom: 1rem; }

.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.dash-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 0.5rem;
    text-align: center;
}

.dash-num { display: block; font-size: 1.4rem; font-weight: 700; color: var(--accent); }
.dash-label { font-size: 0.7rem; color: var(--text-3); line-height: 1.2; }

.objekt-filter {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.objekt-filter label { font-size: 0.9rem; color: var(--text-2); }
.objekt-filter .filter-select {
    flex: 1;
    max-width: 280px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    background: var(--bg-input);
}
.objekt-group-header {
    list-style: none;
    padding: 0.5rem 0.75rem;
    margin-top: 1rem;
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent);
    background: var(--surface);
    border-radius: var(--radius-sm);
}
.objekt-group-header:first-child { margin-top: 0; }
.objekt-list, .maengel-list { list-style: none; }
.objekt-item, .maengel-item {
    padding: 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    cursor: pointer;
}

.objekt-item .status, .maengel-item small { font-size: 0.8rem; color: var(--text-3); }
.maengel-desc { font-weight: 500; }
.empty { color: var(--text-3); padding: 1rem; }

.settings-list .field { margin-bottom: 1rem; }
.settings-reset { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.settings-reset .btn-reset { color: var(--danger); border-color: var(--danger); }
.settings-reset .btn-reset:hover { background: rgba(220, 53, 69, 0.1); }
.settings-list label { display: block; font-size: 0.85rem; margin-bottom: 0.25rem; }
.settings-list input { width: 100%; padding: 0.6rem; border: 1px solid var(--border); border-radius: var(--radius-sm); }

/* Step-Indikator – schlanke Tabs */
.step-chips {
    display: flex;
    gap: 2px;
    padding: 0 1rem 0;
    background: var(--surface);
    overflow-x: auto;
    scrollbar-width: none;
}

.step-chips::-webkit-scrollbar { display: none; }

.step-chip {
    flex-shrink: 0;
    padding: 0.55rem 0.5rem;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-3);
    background: transparent;
    transition: all 0.15s;
}

.step-chip.done {
    color: var(--text-2);
    background: var(--bg);
}

.step-chip.active {
    background: var(--bg-card);
    color: var(--accent);
    font-weight: 600;
}

/* Main – Handy: mehr Padding, Safe Area */
.main {
    padding: 1rem;
    padding-bottom: 0.5rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: calc(100dvh - 180px);
}

.step { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Section – klare Gruppierung */
.section-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.75rem;
    padding-bottom: 0.25rem;
}

/* Cards – reduziert, sachlich */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
}

.card h3 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

/* Inputs – klar, reduziert */
.field {
    margin-bottom: 1rem;
}

.field:last-child { margin-bottom: 0; }

.field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-2);
    margin-bottom: 0.35rem;
}

.field input, .field select, .field textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color 0.15s;
}

.field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    border-color: var(--border-focus);
}

.field textarea { min-height: 80px; resize: vertical; }

/* Select row */
.select-row {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.select-row select { flex: 1; min-width: 0; }

.select-row .btn-add {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: white;
    border: none;
    font-size: 1.25rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.select-row .btn-add:hover { background: var(--accent-hover); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    cursor: pointer;
    min-height: 48px;
    transition: background 0.15s, transform 0.05s;
}

.btn:active { transform: scale(0.98); }

.btn-secondary {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--surface); }

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover { background: var(--accent-hover); }

/* Bottom Nav – Safe Area, große Buttons */
.nav-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 480px;
    margin: 0 auto;
    padding: 0.75rem 1rem;
    padding-bottom: max(0.75rem, var(--safe-bottom));
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.75rem;
    z-index: 100;
}

.nav-bar .btn {
    flex: 1;
    min-height: 52px;
    font-size: 1rem;
}

/* FAB – Kamera, Daumenbereich */
.fab-camera {
    position: fixed;
    bottom: calc(56px + 1rem + var(--safe-bottom));
    right: 1rem;
    width: 56px;
    height: 56px;
    min-width: 56px;
    min-height: 56px;
    border-radius: var(--radius);
    background: var(--accent);
    color: white;
    border: none;
    font-size: 1.35rem;
    cursor: pointer;
    box-shadow: 0 2px 12px rgba(37, 99, 235, 0.4);
    z-index: 99;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fab-camera:active { transform: scale(0.96); }

/* Photo grid */
.photo-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.photo-card {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.photo-card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
}

.photo-card select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    background: var(--bg-input);
    border: none;
    border-top: 1px solid var(--border);
    color: var(--text);
}

.photo-card .btn-del {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    font-size: 0.9rem;
    cursor: pointer;
}

.photo-add-btn {
    width: 100%;
    padding: 1.25rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text-2);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.photo-add-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Defect */
.defect-card {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    border: 1px solid var(--border);
}

.defect-card input {
    flex: 1;
    padding: 0.6rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.9rem;
}

/* Review */
.review-grid p { margin-bottom: 0.5rem; font-size: 0.9rem; color: var(--text-2); }
.review-grid strong { color: var(--text); }

/* Save / Fertig */
.save-intro {
    font-size: 0.95rem;
    color: var(--text-2);
    margin-bottom: 1.25rem;
    line-height: 1.5;
}

.save-summary {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.hint { font-size: 0.85rem; color: var(--text-3); margin-bottom: 0.75rem; }
.step-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--text); }

/* Breadcrumb – dezenter */
.breadcrumb {
    font-size: 0.8rem;
    color: var(--text-3);
    margin-bottom: 1rem;
}

/* Toast/Modal */
.toast-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 1.5rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.toast-overlay.toast-visible { opacity: 1; }
.toast-overlay.toast-hide { opacity: 0; }

.toast-modal {
    background: white;
    border-radius: var(--radius);
    padding: 1.75rem;
    max-width: 340px;
    width: 100%;
    text-align: center;
    box-shadow: 0 16px 40px rgba(0,0,0,0.2);
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.toast-overlay.toast-visible .toast-modal { transform: scale(1); }
.toast-overlay.toast-hide .toast-modal { transform: scale(0.98); }

.toast-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    margin: 0 auto 1rem;
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast-success .toast-icon { background: #d1e7dd; color: var(--success); }
.toast-error .toast-icon { background: #f8d7da; color: var(--danger); }
.toast-info .toast-icon { background: #cff4fc; color: var(--accent); }

.toast-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--text);
}

.toast-message {
    font-size: 0.9rem;
    color: var(--text-2);
    line-height: 1.5;
    margin-bottom: 1.25rem;
}

.toast-btn { width: 100%; }

/* Export-Menü */
.export-menu {
    position: fixed;
    z-index: 1000;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    padding: 0.25rem;
    min-width: 200px;
}

.export-option {
    display: block;
    width: 100%;
    padding: 0.6rem 1rem;
    border: none;
    background: none;
    font-size: 0.9rem;
    color: var(--text);
    text-align: left;
    cursor: pointer;
    border-radius: 4px;
}

.export-option:hover { background: var(--bg-input); }

/* Archiv */
.archive-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.archive-modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    max-width: 480px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 48px rgba(0,0,0,0.25);
}

.archive-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.archive-header h2 { font-size: 1.1rem; font-weight: 600; }

.archive-close {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.archive-content {
    overflow-y: auto;
    padding: 1rem;
}

.archive-empty { color: var(--text-3); text-align: center; padding: 2rem; }

.defect-detail-content {
    padding: 1rem;
    overflow-y: auto;
}
.defect-detail-desc { margin-bottom: 0.75rem; }
.defect-detail-meta { font-size: 0.9rem; color: var(--text-2); margin-bottom: 0.5rem; }
.defect-detail-photos {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}
.defect-detail-no-photos { color: var(--text-3); font-size: 0.9rem; margin-top: 0.5rem; }

.archive-asset {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.archive-asset-info {
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.archive-meta { font-size: 0.8rem; color: var(--text-3); }

.archive-asset-photos {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.archive-photo-wrap {
    width: 90px;
    text-align: center;
}

.photo-error { background: var(--surface); min-width: 80px; min-height: 80px; display: flex; align-items: center; justify-content: center; }
.photo-placeholder { font-size: 1.5rem; color: var(--text-3); }
.archive-photo-wrap img {
    display: block;
    width: 80px;
    height: 80px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    object-fit: cover;
}

.archive-photo-label {
    display: block;
    font-size: 0.65rem;
    color: var(--text-3);
    margin-top: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.archive-photo {
    cursor: pointer;
}

.archive-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.archive-lightbox img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.archive-lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255,255,255,0.2);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    border-radius: 50%;
}

/* Mobile – Touch-Ziele, Lesbarkeit */
@media (max-width: 480px) {
    html { font-size: 16px; }
    .header h1 { font-size: 0.95rem; }
    .view-title { font-size: 1.2rem; }
    .card { padding: 1rem; }
    .field input, .field select, .field textarea {
        padding: 0.85rem 1rem;
        font-size: 16px; /* verhindert Zoom auf iOS */
    }
    .select-row .btn-add { width: 48px; height: 48px; }
    .objekt-item, .maengel-item {
        padding: 1rem;
        min-height: 56px;
    }
    .objekt-filter .filter-select { max-width: none; min-height: 44px; }
    .archive-modal { max-height: 90vh; }
}

/* Desktop */
@media (min-width: 768px) {
    .app-shell { max-width: 520px; margin: 0 auto; }
    .photo-list { grid-template-columns: repeat(3, 1fr); }
    .fab-camera { right: calc(50% - 260px + 1rem); }
}
