/* =====================================================================
   Aufnahmetool - Baustellen-Foto-App
   Mobile-first responsive design
   ===================================================================== */

:root {
    --primary: #1a1a2e;
    --primary-light: #16213e;
    --accent: #0f3460;
    --accent-bright: #e94560;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --gray-50: #f8f9fa;
    --gray-100: #f1f3f5;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-500: #adb5bd;
    --gray-600: #868e96;
    --gray-700: #495057;
    --gray-800: #343a40;
    --gray-900: #212529;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* Header */
.app-header {
    background: var(--primary);
    color: white;
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.header-content {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-img {
    height: 28px;
    width: auto;
}

.header-title {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: -0.3px;
}

/* Main */
.app-main {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px;
    padding-bottom: 80px;
}

/* Sections */
.section { display: none; }
.section.active { display: block; }
.section.hidden { display: none; }

.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--gray-800);
}

/* Search */
.search-container { margin-top: 8px; }

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 14px;
    width: 20px;
    height: 20px;
    color: var(--gray-500);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 14px 40px 14px 44px;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
    background: white;
}

.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(15,52,96,0.1);
}

.btn-clear-search {
    position: absolute;
    right: 12px;
    background: var(--gray-300);
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-700);
}

.btn-clear-search.hidden { display: none; }

/* Search Results */
.search-results {
    margin-top: 8px;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 60vh;
    overflow-y: auto;
    border: 1px solid var(--gray-200);
}

.search-results.hidden { display: none; }

.search-result-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-100);
    cursor: pointer;
    transition: background 0.15s;
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover, .search-result-item:active { background: var(--gray-50); }

.result-projektnr {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--accent);
    font-family: 'SF Mono', 'Consolas', monospace;
}

.result-name {
    font-weight: 600;
    font-size: 0.95rem;
    margin-top: 2px;
}

.result-details {
    font-size: 0.8rem;
    color: var(--gray-600);
    margin-top: 2px;
}

.search-no-results {
    padding: 20px 16px;
    text-align: center;
    color: var(--gray-500);
    font-size: 0.9rem;
}

.search-hint {
    padding: 12px 16px;
    text-align: center;
    color: var(--gray-500);
    font-size: 0.85rem;
}

/* Projekt Header */
.projekt-header {
    margin-bottom: 20px;
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--accent);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 0;
    margin-bottom: 12px;
}

.projekt-info {
    background: white;
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.projekt-info-nr {
    font-family: 'SF Mono', 'Consolas', monospace;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--accent);
}

.projekt-info-name {
    font-weight: 600;
    font-size: 1rem;
    margin-top: 4px;
}

.projekt-info-meta {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 12px;
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--gray-600);
}

.projekt-info-meta dt { font-weight: 500; color: var(--gray-700); }
.projekt-info-meta dd { margin: 0; }

/* Kategorie */
.kategorie-section {
    margin-bottom: 16px;
}

.field-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.pflicht {
    color: var(--danger);
    font-weight: 400;
    font-size: 0.75rem;
}

.pflicht.hidden { display: none; }

.kategorie-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.kategorie-btn {
    padding: 8px 14px;
    border: 2px solid var(--gray-300);
    border-radius: 20px;
    background: white;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    color: var(--gray-700);
}

.kategorie-btn:hover { border-color: var(--accent); color: var(--accent); }
.kategorie-btn.active {
    border-color: var(--accent);
    background: var(--accent);
    color: white;
}

/* Bemerkung */
.bemerkung-section { margin-bottom: 16px; }

.input-bemerkung {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
}

.input-bemerkung:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(15,52,96,0.1);
}

.input-bemerkung.required-highlight { border-color: var(--danger); }

/* Upload Actions */
.upload-section { margin-bottom: 16px; }

.upload-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

.btn-upload-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 20px 12px;
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    background: white;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--gray-600);
    font-size: 0.8rem;
    font-weight: 500;
}

.btn-upload-action:hover, .btn-upload-action:active {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(15,52,96,0.03);
}

/* Preview */
.preview-container { margin-top: 16px; }
.preview-container.hidden { display: none; }

.preview-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--gray-700);
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--gray-200);
}

.preview-item img, .preview-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-item-video::after {
    content: '▶';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.6);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.preview-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2px 4px;
    background: rgba(0,0,0,0.6);
    color: white;
    font-size: 0.6rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preview-size-warn {
    border: 2px solid var(--danger);
}

.upload-summary {
    font-size: 0.8rem;
    color: var(--gray-600);
    margin-bottom: 12px;
}

/* Buttons */
.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover { background: var(--primary-light); }
.btn-primary:disabled { background: var(--gray-400); cursor: not-allowed; }

.btn-upload-send { background: var(--success); }
.btn-upload-send:hover { background: #219a52; }

/* Progress */
.progress-container { margin-top: 16px; }
.progress-container.hidden { display: none; }

.progress-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 8px;
}

.progress-bar {
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.3s;
    width: 0%;
}

.progress-details {
    margin-top: 8px;
    font-size: 0.78rem;
    color: var(--gray-600);
}

/* Success */
.success-container {
    text-align: center;
    padding: 40px 20px;
    margin-top: 16px;
}

.success-container.hidden { display: none; }

.success-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--success);
    color: white;
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.success-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.success-text {
    font-size: 0.9rem;
    color: var(--gray-600);
    margin-bottom: 24px;
}

/* Historie */
.historie-container { margin-top: 24px; }
.historie-container.hidden { display: none; }

.historie-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--gray-700);
}

.historie-list { display: flex; flex-direction: column; }

.historie-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: white;
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    font-size: 0.8rem;
    box-shadow: var(--shadow);
}

.historie-thumb {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--gray-200);
}

.historie-info { flex: 1; min-width: 0; }

.historie-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.historie-meta {
    font-size: 0.7rem;
    color: var(--gray-500);
}

.historie-status {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}

.status-pending { background: #fef3cd; color: #856404; }
.status-abgeholt { background: #d4edda; color: #155724; }
.status-fehler { background: #f8d7da; color: #721c24; }

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--gray-800);
    color: white;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s;
    max-width: 90vw;
    text-align: center;
}

.toast.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* Responsive */
@media (max-width: 400px) {
    .preview-grid { grid-template-columns: repeat(2, 1fr); }
    .upload-actions { gap: 6px; }
    .btn-upload-action { padding: 14px 8px; }
}

@media (min-width: 601px) {
    .app-main { padding: 24px; }
}
