/* Kigaroo Foto-Downloader - Stylesheet */

:root {
    --primary-color: #4CAF50;
    --primary-dark: #388E3C;
    --secondary-color: #2196F3;
    --danger-color: #f44336;
    --warning-color: #ff9800;
    --success-color: #4CAF50;
    --text-color: #333;
    --text-light: #666;
    --bg-color: #f5f5f5;
    --card-bg: #fff;
    --border-color: #ddd;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --radius: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

/* App Container */
.app-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.app-header {
    text-align: center;
    margin-bottom: 30px;
}

.app-header h1 {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.subtitle {
    color: var(--text-light);
    font-size: 1rem;
}

/* Progress Steps */
.progress-steps {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 2px solid var(--border-color);
    opacity: 0.5;
    transition: all 0.3s ease;
}

.step.active {
    opacity: 1;
    border-color: var(--primary-color);
}

.step.completed {
    opacity: 1;
    border-color: var(--success-color);
    background: #e8f5e9;
}

.step-number {
    width: 28px;
    height: 28px;
    background: var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
}

.step.active .step-number {
    background: var(--primary-color);
    color: white;
}

.step.completed .step-number {
    background: var(--success-color);
    color: white;
}

.step.completed .step-number::after {
    content: '\2713';
}

.step.completed .step-number span {
    display: none;
}

.step-label {
    font-size: 0.9rem;
}

/* Info Box (ausklappbar) */
.info-box {
    background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
    border-radius: var(--radius);
    margin-top: 20px;
    border-left: 4px solid var(--primary-color);
}

.info-box summary {
    padding: 18px 25px;
    cursor: pointer;
    color: var(--primary-color);
    font-size: 1.1rem;
    font-weight: 600;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.info-box summary::-webkit-details-marker {
    display: none;
}

.info-box summary::after {
    content: '+';
    font-size: 1.5rem;
    font-weight: 300;
    transition: transform 0.3s;
}

.info-box[open] summary::after {
    content: '−';
}

.info-box summary:hover {
    background: rgba(255, 255, 255, 0.3);
}

.info-box .info-content {
    padding: 0 25px 25px 25px;
}

.info-box h4 {
    color: var(--text-color);
    margin: 20px 0 10px 0;
    font-size: 1.05rem;
}

.info-box h4:first-child {
    margin-top: 0;
}

.info-box p {
    color: var(--text-color);
    line-height: 1.6;
    margin-bottom: 10px;
}

.info-box ul {
    margin: 0 0 10px 20px;
    color: var(--text-color);
    line-height: 1.8;
}

.info-box li {
    margin-bottom: 5px;
}

.info-box a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.info-box a:hover {
    text-decoration: underline;
}

.disclaimer {
    background: rgba(255, 152, 0, 0.15);
    border: 1px solid rgba(255, 152, 0, 0.3);
    border-radius: var(--radius);
    padding: 15px;
    margin-top: 20px;
    font-size: 0.9rem;
    color: #5d4037;
    line-height: 1.5;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 25px;
    box-shadow: var(--shadow);
}

.card h2 {
    font-size: 1.4rem;
    margin-bottom: 15px;
    color: var(--text-color);
}

/* Step Content */
.step-content {
    display: block;
}

.step-content.hidden {
    display: none;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #1976D2;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-link {
    background: none;
    color: var(--text-light);
    text-decoration: underline;
}

.btn-link:hover {
    color: var(--danger-color);
}

.btn-remove-child {
    background: var(--danger-color);
    color: white;
}

.btn-loading.hidden, .btn-text.hidden {
    display: none;
}

/* Info Text */
.info-text {
    color: var(--text-light);
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.info-box {
    background: #e3f2fd;
    padding: 15px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    text-align: center;
    font-size: 1.1rem;
}

/* Messages */
.error-message {
    background: #ffebee;
    color: var(--danger-color);
    padding: 12px;
    border-radius: var(--radius);
    margin-top: 15px;
}

.success-message {
    background: #e8f5e9;
    color: var(--success-color);
    padding: 12px;
    border-radius: var(--radius);
    margin-top: 15px;
}

.status-message {
    padding: 12px;
    border-radius: var(--radius);
    margin-top: 15px;
    text-align: center;
}

.hidden {
    display: none !important;
}

/* Reference Images Section */
.children-container {
    margin-bottom: 20px;
}

.child-section {
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    padding: 15px;
    margin-bottom: 15px;
}

.child-header {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    align-items: center;
}

.child-name {
    flex: 1;
    padding: 10px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
}

.reference-upload {
    position: relative;
}

.reference-input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: #f0f7f0;
}

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

.upload-text {
    color: var(--text-light);
}

.reference-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

.reference-preview img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--radius);
    border: 2px solid var(--border-color);
}

.reference-preview .preview-item {
    position: relative;
}

.reference-preview .remove-btn {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* Progress Bar */
.progress-container {
    margin-top: 20px;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background: var(--border-color);
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    transition: width 0.3s;
}

.progress-text {
    text-align: center;
    margin-top: 10px;
    color: var(--text-light);
}

.status-text {
    text-align: center;
    margin-top: 5px;
    font-size: 0.9rem;
    color: var(--text-light);
}

/* Results Grid */
.results-summary {
    font-size: 1.2rem;
    text-align: center;
    margin-bottom: 20px;
    padding: 15px;
    background: #e8f5e9;
    border-radius: var(--radius);
}

.filter-controls {
    margin-bottom: 20px;
    padding: 15px;
    background: #f5f5f5;
    border-radius: var(--radius);
}

.filter-label {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-label input[type="range"] {
    flex: 1;
    min-width: 150px;
}

.filter-hint {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 5px;
}

.child-filters {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.child-filter {
    padding: 5px 12px;
    background: var(--primary-color);
    color: white;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.child-filter.inactive {
    background: var(--border-color);
    color: var(--text-light);
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
    max-height: 500px;
    overflow-y: auto;
    padding: 5px;
}

.result-item {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.3s;
}

.result-item.selected {
    border-color: var(--primary-color);
}

.result-item img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
}

.result-item .confidence {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 5px;
    font-size: 0.75rem;
    text-align: center;
}

.result-item .child-tag {
    position: absolute;
    top: 5px;
    left: 5px;
    background: var(--primary-color);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
}

.result-item .select-indicator {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--border-color);
}

.result-item.selected .select-indicator {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.result-item.selected .select-indicator::after {
    content: '\2713';
}

.result-item .zoom-btn {
    position: absolute;
    bottom: 30px;
    right: 5px;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10;
}

.result-item:hover .zoom-btn {
    opacity: 1;
}

.result-item .zoom-btn:hover {
    background: var(--primary-color);
}

/* Footer */
.app-footer {
    text-align: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    margin-top: 15px;
    color: var(--text-light);
}

/* Modus-Auswahl */
.mode-selection {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin: 20px 0;
}

.mode-card {
    padding: 25px;
    background: #f5f5f5;
    border: 3px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.mode-card:hover {
    border-color: var(--primary-color);
    background: #e8f5e9;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.mode-card .mode-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.mode-card h3 {
    margin: 0 0 10px 0;
    color: var(--primary-color);
}

.mode-card p {
    color: var(--text-light);
    margin-bottom: 15px;
}

.mode-card ul {
    text-align: left;
    padding-left: 20px;
    color: var(--text-light);
    font-size: 0.9rem;
}

.mode-card ul li {
    margin-bottom: 5px;
}

@media (max-width: 600px) {
    .mode-selection {
        grid-template-columns: 1fr;
    }
}

/* Manueller Modus Galerie */
.gallery-filter {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 15px 0;
    padding: 10px 15px;
    background: #f5f5f5;
    border-radius: var(--radius);
    flex-wrap: wrap;
}

.gallery-filter label {
    font-weight: 500;
}

.gallery-filter select {
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
    min-width: 200px;
}

.selection-count-manual {
    margin-left: auto;
    font-weight: bold;
    color: var(--primary-color);
}

.manual-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 20px 0;
    max-height: 500px;
    overflow-y: auto;
    padding: 5px;
}

.manual-grid .result-item {
    aspect-ratio: 1;
}

@media (max-width: 800px) {
    .manual-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 600px) {
    .manual-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Children List */
.children-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 20px 0;
}

.child-card {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: #f5f5f5;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s;
}

.child-card:hover {
    border-color: var(--primary-color);
    background: #e8f5e9;
}

.child-avatar {
    width: 60px;
    height: 60px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
    font-weight: bold;
}

.child-info {
    flex: 1;
}

.child-info h3 {
    margin: 0 0 5px 0;
    font-size: 1.2rem;
}

.child-info p {
    margin: 0;
    color: var(--text-light);
    font-size: 0.9rem;
}

.child-arrow {
    font-size: 1.5rem;
    color: var(--text-light);
}

/* Sample Grid - 3 Bilder pro Zeile fuer bessere Sichtbarkeit */
.sample-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin: 20px 0;
    max-height: 600px;
    overflow-y: auto;
    padding: 10px;
}

.sample-item {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s;
    aspect-ratio: 1;
}

.sample-item:hover {
    transform: scale(1.05);
}

.sample-item.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

.sample-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sample-item .check-mark {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 28px;
    height: 28px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--border-color);
    opacity: 0;
    transition: opacity 0.2s;
}

.sample-item.selected .check-mark {
    opacity: 1;
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.sample-item.selected .check-mark::after {
    content: '\2713';
    font-size: 16px;
    font-weight: bold;
}

/* Profilbild-Markierung */
.sample-item.profile-image {
    border-color: var(--warning-color);
    box-shadow: 0 0 15px rgba(255, 152, 0, 0.4);
}

.sample-item .profile-badge {
    position: absolute;
    bottom: 5px;
    left: 5px;
    background: var(--warning-color);
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: bold;
}

/* Selection Info */
.selection-info {
    text-align: center;
    padding: 15px;
    background: #e3f2fd;
    border-radius: var(--radius);
    margin: 15px 0;
    font-size: 1.1rem;
}

/* Found Preview */
.found-preview {
    margin-top: 20px;
    padding: 15px;
    background: #e8f5e9;
    border-radius: var(--radius);
}

.found-preview h3 {
    margin: 0 0 10px 0;
    font-size: 1rem;
}

.preview-grid {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 5px 0;
}

.preview-grid img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--radius);
    border: 2px solid var(--primary-color);
}

/* Lightbox fuer Bildvergroesserung */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox.hidden {
    display: none;
}

.lightbox-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    cursor: pointer;
}

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-content img {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: var(--radius);
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    transition: background 0.3s;
    z-index: 2001;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.4);
}

.lightbox-prev,
.lightbox-next {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 2.5rem;
    cursor: pointer;
    transition: background 0.3s;
    z-index: 2001;
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

.lightbox-prev:hover,
.lightbox-next:hover {
    background: rgba(255, 255, 255, 0.4);
}

.lightbox-info {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px 20px;
    border-radius: var(--radius);
    display: flex;
    gap: 20px;
    font-size: 0.9rem;
    z-index: 2001;
}

.lightbox-info #lightbox-confidence {
    color: var(--primary-color);
    font-weight: bold;
}

/* Lightbox Select Button */
.lightbox-select {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-color);
    border: 3px solid var(--border-color);
    padding: 12px 30px;
    border-radius: 30px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s;
    z-index: 2001;
}

.lightbox-select:hover {
    background: white;
    transform: translateX(-50%) scale(1.05);
}

.lightbox-select.selected {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.lightbox-select .select-icon {
    font-size: 1.3rem;
}

.lightbox-shortcuts {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: rgba(255, 255, 255, 0.8);
    padding: 8px 20px;
    border-radius: 20px;
    display: flex;
    gap: 20px;
    font-size: 0.85rem;
    z-index: 2001;
}

.lightbox-shortcuts span {
    white-space: nowrap;
}

/* Responsive */
@media (max-width: 600px) {
    .app-container {
        padding: 10px;
    }

    .app-header h1 {
        font-size: 1.4rem;
    }

    .progress-steps {
        gap: 5px;
    }

    .step {
        padding: 8px 10px;
    }

    .step-label {
        display: none;
    }

    .card {
        padding: 15px;
    }

    .sample-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .results-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }

    .action-buttons {
        flex-direction: column;
    }

    .action-buttons .btn {
        width: 100%;
    }

    .info-box summary {
        padding: 15px;
        font-size: 1rem;
    }

    .info-box .info-content {
        padding: 0 15px 15px 15px;
    }

    .info-box h4 {
        font-size: 1rem;
    }

    .lightbox-shortcuts {
        flex-direction: column;
        gap: 5px;
        text-align: center;
        font-size: 0.75rem;
        padding: 10px 15px;
    }

    .lightbox-select {
        padding: 10px 20px;
        font-size: 1rem;
        bottom: 70px;
    }
}
