:root {
    --primary: #0f172a;       /* Navy */
    --accent: #2563eb;        /* Royal Blue */
    --accent-hover: #1d4ed8;
    --bg-body: #f8fafc;       /* Helles Grau/Weiß */
    --bg-white: #ffffff;
    --text-main: #1e293b;
    --text-light: #64748b;
    --danger: #ef4444;
    --success: #22c55e;
    --border-radius: 6px;
    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --max-width: 1280px; 
}

/* --- RESET & BASE --- */
* { box-sizing: border-box; margin: 0; padding: 0; }

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

a { text-decoration: none; color: inherit; transition: 0.2s; }
img { max-width: 100%; display: block; }
h1, h2, h3 { color: var(--primary); font-weight: 800; line-height: 1.2; margin-bottom: 0.5rem; }
input, select, textarea { font-family: inherit; font-size: 1rem; }

/* --- LAYOUT UTILITIES --- */
.container { 
    max-width: var(--max-width); 
    margin: 0 auto; 
    padding: 0 1rem; 
    width: 100%; 
}

.main-content { flex: 1; padding-bottom: 4rem; }
.text-center { text-align: center; }

/* --- NAVBAR --- */
.navbar { 
    background: var(--bg-white); 
    border-bottom: 1px solid #e2e8f0; 
    position: sticky; 
    top: 0; 
    z-index: 1000; 
    height: 60px; 
    display: flex; 
    align-items: center; 
}

.nav-inner { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    width: 100%; 
}

.logo { 
    font-size: 1.5rem; 
    font-weight: 900; 
    color: var(--primary); 
    letter-spacing: -1px; 
}
.logo span { color: var(--accent); }

.nav-links { display: flex; gap: 8px; align-items: center; }

/* --- BUTTONS & FORMS --- */
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 0.6rem 1.2rem; border-radius: var(--border-radius); font-weight: 600; cursor: pointer; border: none; font-size: 0.95rem; text-decoration: none; transition: 0.2s; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-secondary { background: white; color: var(--text-main); border: 1px solid #cbd5e1; }
.btn-secondary:hover { background: #f1f5f9; border-color: #94a3b8; }
.w-full { width: 100%; }

.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-weight: 600; margin-bottom: 0.4rem; font-size: 0.9rem; }
.form-control { width: 100%; padding: 0.75rem; border: 1px solid #cbd5e1; border-radius: var(--border-radius); background: #fff; }
.form-control:focus { outline: none; border-color: var(--accent); ring: 2px solid rgba(37,99,235,0.1); }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }

/* Pflichtfelder & Hinweise */
.req { color: var(--danger); font-weight: bold; margin-left: 2px; }
.form-note { font-size: 0.85rem; color: var(--text-light); margin-top: 1rem; }

/* --- HERO & SUCHE --- */
.hero { background: var(--primary); color: white; padding: 2rem 1rem 3rem 1rem; text-align: center; }
.hero h1 { color: white; margin-bottom: 0.5rem; font-size: 2rem; }
.hero p { color: #94a3b8; margin-bottom: 2rem; font-size: 1.1rem; }

.search-bar { max-width: 900px; margin: 0 auto; }
.search-form { display: flex; flex-direction: column; gap: 10px; }
.search-input-group { background: white; border-radius: var(--border-radius); padding: 0.8rem 1rem; border: none; box-shadow: 0 4px 6px rgba(0,0,0,0.1); font-size: 1rem; }
.search-btn-hero { padding: 0.8rem 2rem; font-size: 1.1rem; box-shadow: 0 4px 6px rgba(37, 99, 235, 0.3); }

/* --- FILTER BAR --- */
.filter-bar { 
    background: white; 
    border-bottom: 1px solid #e5e7eb; 
    padding: 1rem 0; 
    margin-bottom: 2rem; 
    box-shadow: 0 1px 2px rgba(0,0,0,0.03); 
}

.filter-wrapper { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 20px; 
    align-items: center; 
    justify-content: space-between; 
}

.filter-label {
    font-size: 0.7rem; font-weight: 800; color: #94a3b8; text-transform: uppercase;
    letter-spacing: 0.05em; margin-right: 8px; white-space: nowrap; user-select: none; align-self: center;
}

.filter-group-left { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.filter-group-right { display: flex; align-items: center; margin-left: auto; gap: 10px; }

.filter-select { 
    padding: 0.6rem 2.5rem 0.6rem 1rem; border: 1px solid #d1d5db; border-radius: var(--border-radius);
    background-color: white; font-size: 0.9rem; color: var(--text-main); cursor: pointer; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 0.8rem center; background-size: 1em;
    transition: all 0.2s; min-width: 160px; 
}
.filter-select:hover { border-color: #9ca3af; background-color: #f9fafb; }
.filter-select:focus { outline: none; border-color: var(--accent); }

.price-input-group {
    display: flex; align-items: center; background: white; border: 1px solid #d1d5db;
    border-radius: var(--border-radius); padding: 2px 5px 2px 15px; overflow: hidden; transition: border 0.2s;
}
.price-input-group:focus-within { border-color: var(--accent); }

.filter-input { 
    padding: 0.5rem 0; border: none; width: 80px; flex: 1; font-size: 0.9rem; 
    text-align: center; outline: none; color: var(--text-main); background: transparent; min-width: 0;     
}
.price-separator { color: #cbd5e1; margin: 0 5px; font-weight: 300; }

.btn-go {
    background: #eff6ff; color: var(--accent); border: none; font-weight: 700;
    font-size: 0.8rem; padding: 0.5rem 1rem; border-radius: var(--border-radius);
    cursor: pointer; margin-left: 5px; white-space: nowrap;
}
.btn-go:hover { background: var(--accent); color: white; }

.filter-toggle-btn { display: none; }

/* --- CARDS & GRID --- */
.grid-layout { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 2rem; }
.card { 
    background: white; border: 1px solid #e2e8f0; border-radius: var(--border-radius); 
    overflow: hidden; display: block; position: relative; 
    box-shadow: var(--shadow-card); transition: transform 0.2s, box-shadow 0.2s;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }

.card-img { height: 220px; background: #fff; overflow: hidden; position: relative; display: flex; align-items: center; justify-content: center; border-bottom: 1px solid #f1f5f9; }
.card-img img { width: 100%; height: 100%; object-fit: contain; }
.card-tag { position: absolute; top: 10px; left: 10px; background: rgba(15, 23, 42, 0.9); padding: 4px 10px; border-radius: 4px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; color: white; z-index: 2; box-shadow: 0 2px 4px rgba(0,0,0,0.2); letter-spacing: 0.5px; }

.card-body { padding: 1.25rem; }
.card-title { font-weight: 800; font-size: 1.15rem; margin-bottom: 0.2rem; color: var(--text-main); line-height: 1.3; }
.card-provider { font-size: 0.85rem; color: var(--text-light); margin-bottom: 0.5rem; display: flex; align-items: center; gap: 4px; }

.card-footer { margin-top: 1rem; display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; }
.location-text { 
    color: var(--text-light); font-size: 0.9rem; display: flex; align-items: center; gap: 4px;
    flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; 
}
.price-tag { font-weight: 800; color: var(--accent); font-size: 1.25rem; line-height: 1; flex-shrink: 0; }

/* --- DASHBOARD & CONTENT BOX (FIXED FOR MOBILE ORDER) --- */
/* MOBILE FIRST: Wir nutzen Flexbox um die Reihenfolge zu tauschen */
.dashboard-grid { 
    display: flex; 
    flex-direction: column; 
    gap: 2rem; 
    padding: 2rem 0; 
}

/* WICHTIG: Das 2. Kind (Inserate) kommt nach oben, das 1. Kind (Sidebar) nach unten */
.dashboard-grid > div:nth-child(1) { order: 2; } /* Sidebar (KI/Profil) unten */
.dashboard-grid > div:nth-child(2) { order: 1; } /* Inserate/Entwürfe oben */

.sidebar-card { background: var(--bg-white); padding: 1.5rem; border-radius: 8px; border: 1px solid #e2e8f0; }

.ad-item { background: white; border: 1px solid #e2e8f0; border-radius: 8px; padding: 1rem; margin-bottom: 1rem; display: flex; flex-direction: column; gap: 1rem; }
.ad-item-img { width: 80px !important; height: 80px !important; min-width: 80px; background: #f1f5f9; border-radius: 4px; object-fit: cover; display: block; }
.ad-item-info { display: flex; gap: 1rem; align-items: center; width: 100%; }
.ad-actions { display: flex; gap: 0.5rem; margin-top: auto; width: 100%; }
.ad-actions a, .edit-btn, .delete-btn { flex: 1; display: inline-flex; justify-content: center; align-items: center; text-align: center; font-size: 0.9rem; padding: 0.6rem; border-radius: 6px; font-weight: 600; text-decoration: none; border: 1px solid transparent; transition: 0.2s; cursor: pointer; }
.btn-edit { background: #eff6ff; color: var(--accent); }
.btn-delete { background: #fef2f2; color: var(--danger); }
.empty-state { text-align: center; padding: 3rem; border: 2px dashed #e2e8f0; border-radius: 8px; color: var(--text-light); }

/* CONTENT BOX */
.content-box { 
    background: white; 
    border: 1px solid #e2e8f0; 
    border-radius: var(--border-radius); 
    padding: 2rem; 
    margin-bottom: 2rem; 
    box-shadow: var(--shadow-card); 
    max-width: 850px; 
    margin-left: auto; 
    margin-right: auto;
}

/* --- VIEW PAGE --- */
.view-grid { display: grid; grid-template-columns: 1fr; gap: 2rem; }
.sidebar-price { font-size: 2.5rem; font-weight: 900; color: var(--accent); margin-bottom: 0.2rem; line-height: 1; text-align: center; }
.sidebar-price-label { text-align: center; color: var(--text-light); font-size: 0.9rem; margin-bottom: 1.5rem; }
.seller-widget { display: flex; align-items: center; gap: 1rem; padding: 1rem; background: #f8fafc; border-radius: 8px; border: 1px solid #e2e8f0; margin-bottom: 1.5rem; }
.seller-avatar { width: 50px; height: 50px; background: var(--primary); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; font-weight: 700; flex-shrink: 0; }
.seller-info h4 { margin: 0; font-size: 1rem; font-weight: 700; color: var(--primary); }
.seller-info span { font-size: 0.85rem; color: var(--text-light); }

/* GALERIE & SLIDER */
.gallery-wrapper { position: relative; background: #f1f5f9; border-radius: 8px; overflow: hidden; aspect-ratio: 4/3; display: flex; align-items: center; justify-content: center; border: 1px solid #e2e8f0; }
.gallery-container { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; width: 100%; height: 100%; scroll-behavior: smooth; }
.gallery-item { flex: 0 0 100%; scroll-snap-align: center; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: white; }
.gallery-item img { max-width: 100%; max-height: 100%; object-fit: contain; }

.slider-btn { 
    position: absolute; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; 
    background: rgba(255,255,255,0.9); border-radius: 50%; display: flex; align-items: center; 
    justify-content: center; cursor: pointer; box-shadow: 0 2px 5px rgba(0,0,0,0.2); 
    z-index: 50; font-size: 1.2rem; color: var(--primary); user-select: none; -webkit-tap-highlight-color: transparent; 
}
.slider-btn:hover { background: white; transform: translateY(-50%) scale(1.1); }
.slider-prev { left: 10px; } .slider-next { right: 10px; }

/* --- BILD UPLOAD SYSTEM --- */
.image-upload-section {
    background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px;
    padding: 1.5rem; margin-bottom: 2rem;
}
.upload-group { margin-bottom: 1.5rem; }

.upload-card {
    background: white; border: 2px dashed #cbd5e1; border-radius: 8px;
    padding: 1rem; text-align: center; position: relative; transition: all 0.2s;
    cursor: pointer; min-height: 160px; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
}
.upload-card:hover, .upload-card:focus-within { border-color: var(--accent); background: #eff6ff; }

.upload-preview-img {
    width: 100%; max-width: 250px; height: 140px; object-fit: cover;
    border-radius: 6px; margin-bottom: 10px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.file-input-hidden {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 10;
}

.upload-hint { font-size: 0.85rem; color: #64748b; }
.upload-btn-fake {
    background: var(--primary, #2563eb); color: white; padding: 6px 14px;
    border-radius: 20px; font-size: 0.8rem; margin-top: 5px; pointer-events: none;
}

/* Galerie Live-Vorschau Grid */
.gallery-preview-grid {
    display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; width: 100%; margin-top: 10px;
}
.gallery-thumb {
    width: 60px; height: 60px; object-fit: cover; border-radius: 4px;
    border: 1px solid #cbd5e1; box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* --- QUILL EDITOR & TOOLS --- */
.ql-container {
    background: white; border-bottom-left-radius: 8px; border-bottom-right-radius: 8px;
    font-size: 1rem; font-family: inherit;
}
.ql-toolbar {
    background: #f1f5f9; border-top-left-radius: 8px; border-top-right-radius: 8px; border-color: #d1d5db !important;
}
.ql-container.ql-snow { border-color: #d1d5db !important; }

/* Manuelle Editor Buttons */
.editor-toolbar {
    display: flex; gap: 5px; background: #f1f5f9; border: 1px solid #cbd5e1;
    border-bottom: none; border-radius: 6px 6px 0 0; padding: 5px 10px;
}
.editor-btn {
    background: white; border: 1px solid #cbd5e1; cursor: pointer; font-weight: bold;
    padding: 2px 10px; border-radius: 4px; font-family: serif; font-size: 1.1rem;
}
.editor-btn:hover { background: #e2e8f0; color: var(--accent); }
.textarea-editor { border-top-left-radius: 0; border-top-right-radius: 0; border-top: 1px solid #e2e8f0; }

/* --- BANNER --- */
.welcome-banner {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border-bottom: 1px solid #bfdbfe; padding: 1rem 0; position: relative;
    display: none;
}
.banner-close {
    position: absolute; top: 10px; right: 15px; background: none; border: none;
    font-size: 1.2rem; cursor: pointer; color: #64748b;
}

/* --- FOOTER & MOBILE NAV --- */
.footer-nav {
    display: flex; flex-direction: column; gap: 15px; align-items: center; margin-bottom: 1rem;
}
.footer-sep { display: none; }
.desktop-text { display: none; }
.btn-nav-cta { padding: 0.5rem 0.8rem; font-size: 0.85rem; }

/* --- MOBILE ONLY (max-width 900px) --- */
@media (max-width: 900px) {
    .filter-toggle-btn {
        display: flex; align-items: center; justify-content: space-between; width: 100%;
        background: white; border: 1px solid #d1d5db; padding: 0.8rem 1rem;
        border-radius: var(--border-radius); font-weight: 700; color: var(--text-main);
        cursor: pointer; margin-bottom: 1rem; box-shadow: 0 1px 2px rgba(0,0,0,0.05);
        transition: background 0.2s;
    }
    .filter-toggle-btn:hover { background: #f9fafb; }
    .filter-icon-svg { width: 18px; height: 18px; margin-right: 8px; fill: var(--text-main); vertical-align: middle; }

    .filter-wrapper { display: none; }
    .filter-wrapper.show {
        display: flex; flex-direction: column; align-items: stretch; gap: 0; animation: slideDown 0.3s ease-out;
    }
    .filter-group-left, .filter-group-right {
        width: 100%; flex-direction: column; align-items: stretch; gap: 8px; margin-left: 0; margin-bottom: 1.5rem; padding-top: 0.5rem;
    }
    .filter-label { align-self: flex-start; margin-bottom: 0; margin-left: 2px; font-size: 0.75rem; color: var(--text-light); }
    .filter-select { width: 100%; }
    .price-input-group { width: 100%; padding: 4px 6px 4px 15px; }
    .filter-group-right { border-top: 1px dashed #e2e8f0; padding-top: 1.5rem; margin-bottom: 0; }
    @keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
    .hero { padding: 1.5rem 1rem 2rem 1rem; }
    .hero h1 { font-size: 1.6rem; }
    .text-center-mobile { text-align: center !important; }
}

@media (max-width: 768px) {
    .editor-toolbar { display: none !important; }
    .textarea-editor { border-top-left-radius: var(--border-radius); border-top-right-radius: var(--border-radius); border-top: 1px solid #cbd5e1; }
}

/* --- DESKTOP (min-width 768px) --- */
@media (min-width: 768px) {
    .navbar { height: 70px; }
    .logo { font-size: 1.8rem; }
    .desktop-text { display: inline; }
    .btn-nav-cta { padding: 0.6rem 1.2rem; font-size: 0.95rem; }
    .search-form { flex-direction: row; }
    .search-input-group { width: auto; flex: 1; }
    .search-btn-hero { width: auto; }
    .view-grid { grid-template-columns: 2fr 1fr; align-items: start; }
    .sticky-sidebar { position: sticky; top: 90px; }
    
    /* DASHBOARD DESKTOP: Grid zurücksetzen und Sidebar links */
    .dashboard-grid { 
        display: grid; 
        grid-template-columns: 300px 1fr; 
    }
    /* Reset der Order Property für Desktop */
    .dashboard-grid > div:nth-child(1) { order: initial; }
    .dashboard-grid > div:nth-child(2) { order: initial; }

    .ad-item { flex-direction: row; align-items: center; justify-content: space-between; }
    .ad-item-info { margin-right: 2rem; }
    .ad-actions { width: auto; margin-top: 0; flex-shrink: 0; }
    .ad-actions a { width: auto; padding: 0.5rem 1rem; flex: initial; }
    .form-grid { grid-template-columns: 1fr 1fr; }
    .footer-nav { flex-direction: row; justify-content: center; gap: 20px; flex-wrap: wrap; }
    .footer-sep { display: inline; color: #334155; }
    
    .image-upload-section { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; align-items: stretch; }
    .upload-group { margin-bottom: 0; display: flex; flex-direction: column; }
    .upload-card { flex: 1; min-height: 200px; }
}

/* --- Listen im Inserat schön anzeigen (Fix für fehlende Einrückung) --- */
.description-content ul, .description-content ol {
    margin-left: 0;
    padding-left: 1.5rem; /* Sorgt für den Abstand links */
    margin-bottom: 1rem;
    list-style-position: outside;
}

.description-content li {
    margin-bottom: 0.25rem;
    list-style-type: disc; /* Erzwingt runde Punkte */
}

/* Falls die KI <p> Tags macht */
.description-content p {
    margin-bottom: 1rem;
}

/* Container für die Thumbnails */
.thumbnails-container {
    display: flex;
    gap: 10px;          /* Abstand zwischen Bildern */
    overflow-x: auto;   /* Scrollbar wenn zu viele Bilder */
    padding-bottom: 5px;
    scroll-behavior: smooth;
}

/* Einzelnes Thumbnail */
.thumb-item {
    width: 70px;        /* Feste Breite */
    height: 50px;       /* Feste Höhe */
    flex-shrink: 0;     /* Nicht zusammendrücken lassen */
    cursor: pointer;
    border-radius: 4px;
    border: 2px solid transparent;
    opacity: 0.6;       /* Leicht ausgegraut wenn inaktiv */
    transition: 0.2s;
    overflow: hidden;
}

/* Hover & Aktiv-Status */
.thumb-item:hover, .thumb-item.active {
    opacity: 1;
    border-color: var(--accent); /* Blauer Rahmen */
}

.thumb-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;  /* Bild füllt Box schön aus */
}