/* =========================================
   Gebrauchtmaschinen-Verwaltung
   Stylesheet – passt zu mtdruck.de
   ========================================= */

* { box-sizing: border-box; }

body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    color: #333;
    background: #f5f5f5;
    margin: 0;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

a { color: #c8102e; text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; display: block; }

/* === Site-Banner mit Slider-Bild === */
.site-banner {
    background-color: #000000;
    width: 100%;
    overflow: hidden;
    line-height: 0;
}
.banner-image {
    background-image: url('https://mtdruck.de/media/images/Head-Slider_StrudelNEU_24-07-23.jpg');
    background-repeat: no-repeat;
    background-position: center center;
    background-color: #000000;
    background-size: contain;
    /* Bild zentriert; links/rechts schwarz aufgefüllt */
    height: 240px;
    width: 100%;
}
@media (max-width: 1200px) {
    .banner-image { height: 200px; }
}
@media (max-width: 768px) {
    .banner-image { height: 140px; }
}
@media (max-width: 480px) {
    .banner-image { height: 100px; }
}

/* === Site Header === */
.site-header {
    background: white;
    border-bottom: 3px solid #c8102e;
    padding: 20px 0;
    margin-bottom: 30px;
}
.site-header h1 {
    margin: 10px 0 5px 0;
    color: #222;
    font-size: 28px;
}
.site-header .subtitle {
    color: #666;
    margin: 0;
}
.back-link {
    display: inline-block;
    color: #666;
    font-size: 14px;
    margin-bottom: 10px;
}

/* === Toolbar === */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 25px;
    padding: 15px 20px;
    background: white;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.toolbar .info { margin: 0; color: #555; }

/* === Buttons === */
.btn {
    display: inline-block;
    padding: 10px 18px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: background 0.15s;
    text-align: center;
}
.btn-primary { background: #c8102e; color: white; }
.btn-primary:hover { background: #a00d24; text-decoration: none; }
.btn-secondary { background: #555; color: white; }
.btn-secondary:hover { background: #333; text-decoration: none; }
.btn-danger { background: #b00; color: white; }
.btn-danger:hover { background: #800; text-decoration: none; }
.btn-small { padding: 6px 12px; font-size: 13px; }
.btn-large { padding: 14px 24px; font-size: 16px; }
.btn-block { display: block; width: 100%; }

/* === Maschinen-Grid (Übersicht) === */
.machine-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}
.machine-card {
    background: white;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    transition: transform 0.15s, box-shadow 0.15s;
    color: #333;
    display: block;
}
.machine-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    text-decoration: none;
}
.machine-card.is-sold .card-image img {
    opacity: 0.6;
    filter: grayscale(40%);
}
.card-image {
    position: relative;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: #eee;
}
.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.card-image .no-image {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    color: #999; font-style: italic;
}
.sold-banner {
    position: absolute;
    top: 12px; right: -35px;
    background: #c8102e;
    color: white;
    padding: 5px 40px;
    font-weight: bold;
    font-size: 13px;
    transform: rotate(35deg);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    letter-spacing: 1px;
}
.card-body {
    padding: 15px;
}
.card-body h2,
.card-body .card-title {
    margin: 0 0 6px 0;
    font-size: 17px;
    color: #222;
    font-weight: bold;
}
.card-body .meta {
    color: #666;
    font-size: 13px;
    margin: 0 0 10px 0;
}
.card-body .price {
    color: #c8102e;
    font-weight: bold;
    font-size: 18px;
    margin: 0;
}

/* === Detail-Seite === */
.detail-grid {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 30px;
    background: white;
    padding: 25px;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    margin-bottom: 25px;
}
@media (max-width: 768px) {
    .detail-grid { grid-template-columns: 1fr; }
}
.gallery .main-image {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: contain;
    background: #f5f5f5;
    border-radius: 4px;
}
.thumbnails {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    overflow-x: auto;
}
.thumb {
    width: 80px; height: 60px;
    object-fit: cover;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 4px;
    flex-shrink: 0;
}
.thumb:hover, .thumb.active { border-color: #c8102e; }
.no-image-large {
    width: 100%; aspect-ratio: 4/3;
    background: #f0f0f0;
    display: flex; align-items: center; justify-content: center;
    color: #999;
}
.price-large {
    font-size: 28px;
    color: #c8102e;
    font-weight: bold;
    margin: 0 0 20px 0;
}
.spec-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 25px;
}
.spec-table th, .spec-table td {
    text-align: left;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
    vertical-align: top;
    font-weight: normal;
}
.spec-table th {
    color: #666;
    width: 45%;
    padding-right: 15px;
}
.contact-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.contact-actions .btn { flex: 1; min-width: 140px; }

.description {
    background: white;
    padding: 25px;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.description h2 { margin-top: 0; color: #222; }

.sold-notice {
    background: #fff3cd;
    color: #856404;
    padding: 8px 15px;
    border-radius: 4px;
    display: inline-block;
    margin-top: 10px;
}

/* === Kontakt-Box === */
.contact-box {
    background: white;
    padding: 20px;
    border-radius: 6px;
    margin-top: 30px;
    text-align: center;
    border-left: 4px solid #c8102e;
}
.contact-box h3 { margin-top: 0; }

.empty-state {
    background: white;
    padding: 40px 20px;
    border-radius: 6px;
    text-align: center;
    color: #666;
}

/* === Footer === */
.site-footer {
    margin-top: 50px;
    padding: 25px 0;
    background: #333;
    color: #ccc;
    text-align: center;
    font-size: 13px;
}
.site-footer a { color: #ccc; }

/* =========================================
   ADMIN-BEREICH
   ========================================= */
body.admin {
    background: #ecedf0;
}
.admin-header {
    background: #222;
    color: white;
    padding: 15px 0;
    margin-bottom: 25px;
}
.admin-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.admin-header h1 {
    margin: 0;
    font-size: 20px;
}
.admin-header nav a {
    color: #ccc;
    margin-left: 15px;
    font-size: 14px;
}
.admin-header nav a:hover { color: white; }

.login-box {
    background: white;
    padding: 30px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.login-box h1 { margin-top: 0; }
.login-box label {
    display: block;
    margin-bottom: 15px;
    font-weight: 500;
}
.login-box input[type="password"],
.login-box input[type="text"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 16px;
    margin-top: 5px;
}

/* === Alerts === */
.alert {
    padding: 12px 18px;
    border-radius: 4px;
    margin-bottom: 20px;
}
.alert-error   { background: #fee; color: #900; border-left: 4px solid #c00; }
.alert-success { background: #efe; color: #060; border-left: 4px solid #0a0; }
.alert-info    { background: #eef; color: #006; border-left: 4px solid #00c; }

/* === Admin-Liste === */
.admin-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.admin-item {
    background: white;
    border-radius: 6px;
    padding: 12px;
    display: flex;
    gap: 15px;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.admin-item.is-hidden { opacity: 0.6; }
.admin-thumb {
    width: 100px; height: 75px;
    flex-shrink: 0;
}
.admin-thumb img {
    width: 100%; height: 100%;
    object-fit: cover;
    border-radius: 4px;
}
.no-image-small {
    width: 100%; height: 100%;
    background: #f0f0f0;
    display: flex; align-items: center; justify-content: center;
    color: #999; font-size: 12px;
    border-radius: 4px;
}
.admin-info { flex: 1; }
.admin-info h3 { margin: 0 0 4px 0; font-size: 16px; }
.admin-info .meta { color: #666; font-size: 13px; margin: 0 0 8px 0; }
.admin-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}
.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: bold;
    margin-left: 5px;
    vertical-align: middle;
}
.status-badge.sold   { background: #c8102e; color: white; }
.status-badge.hidden { background: #888; color: white; }

@media (max-width: 600px) {
    .admin-item { flex-direction: column; align-items: stretch; }
    .admin-thumb { width: 100%; height: 180px; }
    .admin-actions { justify-content: stretch; }
    .admin-actions .btn, .admin-actions form { flex: 1; }
    .admin-actions .btn { width: 100%; }
}

/* === Kategorie-Überschriften (öffentliche Liste) === */
.category-heading {
    color: #c8102e;
    font-size: 22px;
    margin: 30px 0 15px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #c8102e;
    display: flex;
    align-items: baseline;
    gap: 10px;
}
.category-heading:first-of-type { margin-top: 0; }
.category-heading .cat-count {
    color: #888;
    font-size: 14px;
    font-weight: normal;
}
.machine-grid + .category-heading { margin-top: 40px; }

/* === Filter-Bar === */
.filter-bar {
    background: white;
    padding: 15px 20px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: space-between;
    align-items: center;
}
.filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.filter-btn {
    display: inline-block;
    padding: 7px 14px;
    background: #f5f5f5;
    color: #555;
    border-radius: 20px;
    text-decoration: none;
    font-size: 13px;
    border: 1px solid transparent;
    transition: all 0.15s;
}
.filter-btn:hover {
    background: #e8e8e8;
    text-decoration: none;
    color: #c8102e;
}
.filter-btn.active {
    background: #c8102e;
    color: white;
    font-weight: 500;
}
.filter-btn .count {
    opacity: 0.7;
    font-size: 12px;
}
.sort-control {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #666;
}
.sort-control select {
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    background: white;
    cursor: pointer;
}
@media (max-width: 600px) {
    .filter-bar { flex-direction: column; align-items: stretch; }
    .sort-control { justify-content: space-between; }
}

/* === Textbausteine (Detail-Seite) === */
.textblocks {
    background: white;
    padding: 25px;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    margin-top: 20px;
}
.textblocks h2 { margin-top: 0; color: #222; }
.textblock-display {
    list-style: none;
    padding: 0;
    margin: 0;
}
.textblock-display li {
    padding: 12px 0 12px 28px;
    border-bottom: 1px solid #eee;
    position: relative;
}
.textblock-display li:last-child { border-bottom: none; }
.textblock-display li::before {
    content: "\2713";
    color: #4a8;
    font-weight: bold;
    position: absolute;
    left: 0;
    top: 12px;
    font-size: 18px;
}
.textblock-display li strong { color: #333; }

/* === Textbausteine (Admin-Auswahlliste) === */
.textblock-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}
.textblock-item {
    display: flex !important;
    align-items: flex-start;
    gap: 10px;
    padding: 10px;
    background: #f7f7f7;
    border-radius: 4px;
    cursor: pointer;
    font-weight: normal !important;
    transition: background 0.15s;
}
.textblock-item:hover { background: #f0f0f0; }
.textblock-item input[type="checkbox"] {
    margin-top: 3px;
    flex-shrink: 0;
    width: auto !important;
    transform: scale(1.3);
}
.textblock-item span {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.textblock-item strong { color: #333; font-size: 14px; }
.textblock-item small { color: #777; font-size: 12px; line-height: 1.3; }

/* === Edit-Form === */
.edit-form fieldset {
    background: white;
    border: none;
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.edit-form legend {
    font-weight: bold;
    color: #c8102e;
    padding: 0 8px;
    font-size: 16px;
}
.edit-form label {
    display: block;
    margin-bottom: 15px;
    font-weight: 500;
    color: #444;
}
.edit-form input[type="text"],
.edit-form input[type="number"],
.edit-form input[type="file"],
.edit-form select,
.edit-form textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 16px; /* 16px verhindert Zoom auf iOS */
    margin-top: 5px;
    font-family: inherit;
}
.edit-form select { background: white; cursor: pointer; }
.edit-form input[type="file"] { padding: 8px; }
.edit-form textarea { resize: vertical; min-height: 80px; }
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}
@media (max-width: 600px) {
    .form-row { grid-template-columns: 1fr; }
}
.checkbox-inline {
    font-weight: normal;
    display: flex !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
.checkbox-inline input { margin-top: 0 !important; width: auto !important; }
.hint {
    color: #777;
    font-size: 13px;
    margin: 5px 0 0 0;
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.img-thumb {
    position: relative;
    background: #f5f5f5;
    border-radius: 4px;
    padding: 8px;
    text-align: center;
}
.img-thumb img {
    width: 100%;
    height: 110px;
    object-fit: cover;
    border-radius: 3px;
    margin-bottom: 6px;
}
.img-thumb .badge {
    position: absolute;
    top: 5px; left: 5px;
    background: #c8102e;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}
@media (max-width: 600px) {
    .form-actions { flex-direction: column; }
}

/* === Sofort-Upload (AJAX) === */
.btn-upload {
    display: inline-block;
    padding: 16px 28px;
    font-size: 17px;
    cursor: pointer;
    width: 100%;
    text-align: center;
    box-sizing: border-box;
}
.btn-disabled {
    cursor: not-allowed;
}
.upload-status {
    background: #e7f3ff;
    border-left: 4px solid #0066cc;
    padding: 10px 15px;
    margin: 10px 0;
    border-radius: 4px;
    font-size: 14px;
}
