/**
 * Pfeifensammlung - Stylesheet
 * Mobile-First Design
 */

/* === Reset & Basis === */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #5d4e37;
    --primary-light: #8b7355;
    --primary-dark: #3d3225;
    --accent: #c9a66b;
    --bg: #f5f3f0;
    --bg-card: #ffffff;
    --text: #333333;
    --text-light: #666666;
    --border: #e0ddd8;
    --success: #4caf50;
    --danger: #e74c3c;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --radius: 8px;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* === Layout === */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

main.container {
    flex: 1;
    padding-top: 1.5rem;
    padding-bottom: 2rem;
}

/* === Header === */
.site-header {
    background: var(--primary);
    color: white;
    padding: 1rem 0;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.site-header .container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.site-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.site-header nav {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.site-header nav a {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: background 0.2s, color 0.2s;
}

.site-header nav a:hover,
.site-header nav a.active {
    background: rgba(255,255,255,0.15);
    color: white;
}

.logout-form {
    display: inline;
}

.logout-link {
    background: none;
    border: none;
    color: var(--accent) !important;
    cursor: pointer;
    font: inherit;
    padding: 0.4rem 0.8rem;
}

/* === Footer === */
.site-footer {
    background: var(--primary-dark);
    color: rgba(255,255,255,0.7);
    padding: 1.5rem 0;
    text-align: center;
    font-size: 0.9rem;
    margin-top: auto;
}

/* === Buttons === */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

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

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

.btn-secondary {
    background: var(--accent);
    color: var(--primary-dark);
}

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

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

/* === Karten-Bereich === */
.map-section {
    margin-bottom: 2rem;
}

.map-intro {
    text-align: center;
    margin-bottom: 1rem;
}

.map-intro p {
    color: var(--text-light);
}

.stats {
    margin-top: 0.5rem;
    font-size: 0.95rem;
}

.map-container {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

#world-map {
    width: 100%;
    height: 60vh;
    min-height: 400px;
    max-height: 600px;
}

.map-button {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1000;
    background: white;
    border: 2px solid var(--primary);
    color: var(--primary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.map-button:hover {
    background: var(--primary);
    color: white;
}

.map-button.hidden {
    display: none;
}

/* Land-Info Panel */
.country-info,
.country-pipes-inline {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-top: 1rem;
    box-shadow: var(--shadow);
    text-align: center;
}

.country-info.hidden,
.country-pipes-inline.hidden {
    display: none;
}

.country-info h3,
.country-pipes-inline h3 {
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.country-info p {
    margin-bottom: 1rem;
    color: var(--text-light);
}

/* === Pfeifen-Grid === */
.pipes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.pipe-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
    color: inherit;
    display: block;
}

.pipe-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.pipe-card-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: var(--border);
}

.pipe-card-content {
    padding: 1rem;
}

.pipe-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.pipe-card .country {
    font-size: 0.9rem;
    color: var(--text-light);
}

.pipe-card .details {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 0.5rem;
}

/* Keine Ergebnisse */
.no-results,
.loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-light);
    grid-column: 1 / -1;
}

/* === Filter-Leiste === */
.filter-bar {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.search-input,
.country-filter {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    flex: 1;
    min-width: 200px;
}

.search-input:focus,
.country-filter:focus {
    outline: none;
    border-color: var(--primary);
}

/* === Pfeifen-Detail === */
.pipe-detail-section,
.country-pipes-section,
.all-pipes-section {
    margin-bottom: 2rem;
}

.back-link {
    display: inline-block;
    margin-bottom: 1rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.back-link:hover {
    text-decoration: underline;
}

.pipe-detail {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.pipe-detail h2 {
    color: var(--primary);
    margin-bottom: 1rem;
}

/* Bildergalerie */
.image-gallery {
    margin-bottom: 1.5rem;
}

.main-image {
    margin-bottom: 1rem;
}

.main-image img {
    width: 100%;
    max-height: 500px;
    object-fit: contain;
    border-radius: var(--radius);
    background: var(--bg);
}

.thumbnails {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.thumbnail {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--radius);
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.thumbnail:hover {
    opacity: 1;
}

/* Pfeifen-Info */
.pipe-info p {
    margin-bottom: 0.5rem;
}

.pipe-info .description {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* === Login === */
.login-section {
    max-width: 400px;
    margin: 2rem auto;
}

.login-section h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--primary);
}

.login-form {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.error-message {
    background: #fee;
    color: var(--danger);
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    text-align: center;
}

.success-message {
    background: #e8f5e9;
    color: #2e7d32;
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    text-align: center;
    font-weight: 500;
}

/* === Formulare === */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

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

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
}

.checkbox-group label {
    margin: 0;
    font-weight: normal;
    cursor: pointer;
}

/* === Admin-Bereich === */
.admin-section h2 {
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.welcome {
    color: var(--text-light);
    margin-bottom: 1.5rem;
}

/* Tabs */
.admin-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0.5rem;
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    border-radius: var(--radius) var(--radius) 0 0;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-light);
    transition: background 0.2s, color 0.2s;
}

.tab-btn:hover {
    background: var(--bg);
}

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

.tab-content {
    display: none;
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.tab-content.active {
    display: block;
}

.tab-content h3 {
    margin-bottom: 1rem;
    color: var(--primary);
}

/* Upload-Bereich */
.image-upload-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border);
}

.image-upload-section.hidden {
    display: none;
}

.image-upload-section h4 {
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.hint {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 2rem;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.upload-label:hover {
    border-color: var(--primary);
    background: rgba(93, 78, 55, 0.05);
}

.upload-icon {
    font-size: 2rem;
}

.file-input {
    display: none;
}

/* Bild-Vorschau */
.image-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1rem 0;
}

.preview-item {
    position: relative;
    width: 100px;
    height: 100px;
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius);
}

.preview-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}

/* Hochgeladene Bilder */
.uploaded-images {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1rem 0;
}

.uploaded-item {
    position: relative;
    width: 100px;
    height: 100px;
}

.uploaded-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius);
    border: 2px solid var(--success);
}

/* Admin-Pfeifen-Liste */
.admin-pipes-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.admin-pipe-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg);
    border-radius: var(--radius);
    transition: background 0.2s;
}

.admin-pipe-item:hover {
    background: var(--border);
}

.admin-pipe-thumb {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--radius);
    background: var(--border);
    flex-shrink: 0;
}

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

.admin-pipe-info h4 {
    margin-bottom: 0.25rem;
    color: var(--primary);
}

.admin-pipe-info p {
    font-size: 0.9rem;
    color: var(--text-light);
}

.admin-pipe-actions {
    display: flex;
    gap: 0.5rem;
}

/* === Modal === */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    overflow-y: auto;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
}

.modal-content h3 {
    margin-bottom: 1.5rem;
    color: var(--primary);
}

.edit-images {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.edit-image-item {
    position: relative;
    width: 80px;
    height: 80px;
}

.edit-image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius);
}

.edit-image-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.8rem;
    line-height: 1;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

/* === Leaflet Anpassungen === */
.leaflet-container {
    font-family: inherit;
}

.leaflet-popup-content-wrapper {
    border-radius: var(--radius);
}

.leaflet-popup-content {
    margin: 0.75rem 1rem;
}

.country-popup h4 {
    margin: 0 0 0.5rem 0;
    color: var(--primary);
}

.country-popup p {
    margin: 0 0 0.75rem 0;
    font-size: 0.9rem;
}

.country-popup .btn {
    display: block;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

/* === Responsive === */
@media (max-width: 768px) {
    .site-header .container {
        flex-direction: column;
        text-align: center;
    }
    
    .site-header nav {
        justify-content: center;
    }
    
    #world-map {
        height: 50vh;
        min-height: 300px;
    }
    
    .pipes-grid {
        grid-template-columns: 1fr;
    }
    
    .admin-pipe-item {
        flex-direction: column;
        text-align: center;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        padding: 1.5rem;
    }
    
    .tab-btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .filter-bar {
        flex-direction: column;
    }
    
    .search-input,
    .country-filter {
        min-width: 100%;
    }
    
    .admin-tabs {
        flex-wrap: wrap;
    }
}
