/* ══════════════════════════════════════════════
   ME Marktplatz – Mittelalterliches Theme
   ══════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=IM+Fell+English:ital@0;1&display=swap');

:root {
    --bg-dark:       #0d0a06;
    --bg-medium:     #1a1208;
    --bg-card:       #211808;
    --bg-card-hover: #2c2010;
    --bg-panel:      #17100a;
    --border:        #4a3510;
    --border-gold:   #8b6914;
    --border-bright: #c8960c;
    --gold:          #f0c040;
    --gold-light:    #ffd878;
    --gold-dim:      #a07820;
    --text:          #e8d5a8;
    --text-dim:      #8a7050;
    --text-bright:   #fff8e8;
    --sell-color:    #ff6b35;
    --buy-color:     #4caf7d;
    --red:           #c0392b;
    --shadow:        rgba(0,0,0,0.7);
}

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

html { scroll-behavior: smooth; }

body {
    background: var(--bg-dark);
    background-image:
        radial-gradient(ellipse at 20% 20%, rgba(100,60,0,0.12) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 80%, rgba(80,40,0,0.10) 0%, transparent 60%),
        url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23362010' fill-opacity='0.15'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    color: var(--text);
    font-family: 'IM Fell English', serif;
    min-height: 100vh;
    position: relative;
}

/* ── Partikel ── */
.particles { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.particle {
    position: absolute;
    bottom: -10px;
    width: 4px; height: 4px;
    background: var(--gold-dim);
    border-radius: 50%;
    animation: floatUp linear infinite;
}
@keyframes floatUp {
    0%   { transform: translateY(0) rotate(0deg); opacity: 0; }
    10%  { opacity: 1; }
    90%  { opacity: 0.5; }
    100% { transform: translateY(-100vh) rotate(720deg); opacity: 0; }
}

/* ── Header ── */
.site-header {
    position: sticky; top: 0; z-index: 100;
    background: linear-gradient(to bottom, #110d05, #1a1208);
    border-bottom: 2px solid var(--border-gold);
    box-shadow: 0 4px 20px rgba(0,0,0,0.8), 0 1px 0 var(--gold-dim);
    padding: 0 24px;
}

.header-inner {
    max-width: 1600px; margin: 0 auto;
    display: flex; align-items: center; gap: 24px;
    height: 72px;
}

.header-logo { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.logo-icon { width: 40px; height: 40px; image-rendering: pixelated; filter: drop-shadow(0 0 6px rgba(240,192,64,0.5)); }
.header-logo h1 {
    font-family: 'Cinzel', serif; font-size: 1.4rem;
    color: var(--gold); text-shadow: 0 0 12px rgba(240,192,64,0.4);
    white-space: nowrap; letter-spacing: 2px;
}
.header-sub { font-size: 0.72rem; color: var(--text-dim); font-style: italic; }

.header-search { flex: 1; max-width: 400px; position: relative; }
.header-search input {
    width: 100%;
    background: rgba(0,0,0,0.5);
    border: 1px solid var(--border-gold);
    border-radius: 4px;
    color: var(--text);
    padding: 8px 14px;
    font-family: 'IM Fell English', serif;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.header-search input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(240,192,64,0.2);
}
.header-search input::placeholder { color: var(--text-dim); }

.search-dropdown {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0;
    background: #1a1208; border: 1px solid var(--border-gold);
    border-radius: 4px; z-index: 200; overflow: hidden;
    box-shadow: 0 8px 24px rgba(0,0,0,0.8);
}
.search-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border);
}
.search-item:hover { background: var(--bg-card-hover); }
.search-item img { image-rendering: pixelated; }

.header-stats { display: flex; gap: 20px; font-size: 0.82rem; color: var(--text-dim); white-space: nowrap; }
.header-stats span { display: flex; align-items: center; gap: 4px; }
.header-stats b { color: var(--gold); }

/* ── Layout ── */
.main-layout { display: flex; max-width: 1600px; margin: 0 auto; padding: 24px 24px 0; gap: 24px; }

/* ── Kategorie-Nav ── */
.category-nav {
    width: 200px; flex-shrink: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 16px 12px;
    height: fit-content;
    position: sticky; top: 90px;
    box-shadow: inset 0 0 30px rgba(0,0,0,0.4);
}

.nav-title {
    font-family: 'Cinzel', serif; font-size: 0.85rem;
    color: var(--gold); letter-spacing: 1px;
    margin-bottom: 14px; padding-bottom: 10px;
    border-bottom: 1px solid var(--border-gold);
    text-align: center;
}

.cat-link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px; margin-bottom: 4px;
    border-radius: 4px; text-decoration: none;
    color: var(--text-dim); font-size: 0.85rem;
    transition: all 0.15s;
    border: 1px solid transparent;
}
.cat-link:hover { background: rgba(138,105,20,0.15); color: var(--text); border-color: var(--border); }
.cat-link.active { background: rgba(138,105,20,0.25); color: var(--gold); border-color: var(--border-gold); }
.cat-icon { width: 20px; height: 20px; image-rendering: pixelated; flex-shrink: 0; }

/* ── Content ── */
.content { flex: 1; min-width: 0; }

.category-header {
    display: flex; align-items: center; gap: 16px;
    padding: 16px 20px; margin-bottom: 20px;
    background: linear-gradient(135deg, var(--bg-card), var(--bg-panel));
    border: 1px solid var(--border-gold);
    border-radius: 6px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.5);
    position: relative; overflow: hidden;
}
.category-header::before {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(90deg, rgba(138,105,20,0.08) 0%, transparent 100%);
}
.cat-header-icon { width: 48px; height: 48px; image-rendering: pixelated; position: relative; }
.category-header h2 { font-family: 'Cinzel', serif; font-size: 1.3rem; color: var(--gold); letter-spacing: 1px; position: relative; }
.cat-desc { font-size: 0.8rem; color: var(--text-dim); font-style: italic; position: relative; }

/* ── Item-Grid ── */
.item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    padding-bottom: 40px;
}

.item-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px 10px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.item-card::before {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(135deg, rgba(138,105,20,0) 0%, rgba(138,105,20,0.06) 100%);
    opacity: 0; transition: opacity 0.2s;
}
.item-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-gold);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.6), 0 0 0 1px rgba(138,105,20,0.3);
}
.item-card:hover::before { opacity: 1; }

.item-img-wrap {
    width: 48px; height: 48px;
    margin: 0 auto 8px;
    display: flex; align-items: center; justify-content: center;
}
.item-img-wrap img { width: 48px; height: 48px; image-rendering: pixelated; }

.item-name {
    font-size: 0.78rem; color: var(--text);
    line-height: 1.3; margin-bottom: 6px;
    min-height: 2.2em;
}

.item-prices { display: flex; flex-direction: column; gap: 3px; }
.sell-price { color: var(--sell-color); font-size: 0.76rem; font-weight: 600; }
.buy-price  { color: var(--buy-color);  font-size: 0.76rem; }
.no-orders  { color: var(--text-dim); font-size: 0.72rem; font-style: italic; }
.price-loading { color: var(--text-dim); font-size: 0.7rem; }

/* ── Item-Detail Panel ── */
.item-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-gold);
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.7), inset 0 0 40px rgba(0,0,0,0.3);
    position: relative;
    animation: slideDown 0.25s ease-out;
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.btn-close {
    position: absolute; top: 16px; right: 16px;
    background: rgba(100,40,0,0.4);
    border: 1px solid var(--border);
    color: var(--text-dim); padding: 6px 12px;
    border-radius: 4px; cursor: pointer; font-size: 0.82rem;
    transition: all 0.15s; font-family: 'IM Fell English', serif;
}
.btn-close:hover { background: rgba(150,60,0,0.5); color: var(--text); border-color: var(--sell-color); }

.detail-header {
    display: flex; align-items: flex-start; gap: 20px;
    margin-bottom: 24px; padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}
.detail-icon { width: 64px; height: 64px; image-rendering: pixelated; flex-shrink: 0; }
.detail-title { font-family: 'Cinzel', serif; font-size: 1.4rem; color: var(--gold); margin-bottom: 10px; }
.detail-stats { display: flex; flex-wrap: wrap; gap: 16px; font-size: 0.85rem; color: var(--text-dim); }
.detail-stats span b { color: var(--text); }

.orders-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
@media (max-width: 700px) { .orders-grid { grid-template-columns: 1fr; } }

.orders-title {
    font-family: 'Cinzel', serif; font-size: 0.95rem;
    margin-bottom: 12px; padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.sell-title { color: var(--sell-color); }
.buy-title  { color: var(--buy-color); }

.orders-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.orders-table thead th {
    color: var(--text-dim); font-weight: 400; font-style: italic;
    padding: 6px 8px; border-bottom: 1px solid var(--border);
    text-align: left;
}
.orders-table tbody tr { border-bottom: 1px solid rgba(74,53,16,0.3); transition: background 0.1s; }
.orders-table tbody tr:hover { background: rgba(138,105,20,0.08); }
.orders-table td { padding: 7px 8px; }
.price-cell { font-weight: 600; }
.price-cell.sell { color: var(--sell-color); }
.price-cell.buy  { color: var(--buy-color); }
.trader { color: var(--text-dim); font-size: 0.8rem; }

.history-section h3 { font-family: 'Cinzel', serif; font-size: 0.9rem; color: var(--gold-dim); margin-bottom: 12px; }
.history-table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
.history-table thead th { color: var(--text-dim); font-weight: 400; font-style: italic; padding: 5px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.history-table td { padding: 6px 8px; border-bottom: 1px solid rgba(74,53,16,0.2); }
.time-cell { color: var(--text-dim); }

.no-data { color: var(--text-dim); font-style: italic; font-size: 0.85rem; padding: 12px 0; }
.loading-spinner { text-align: center; padding: 40px; color: var(--text-dim); font-style: italic; }

/* ── Footer ── */
.site-footer {
    text-align: center; padding: 24px;
    color: var(--text-dim); font-style: italic; font-size: 0.82rem;
    border-top: 1px solid var(--border);
    margin-top: 40px;
}

/* ── Utility ── */
.hidden { display: none !important; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border-gold); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dim); }

/* ── Responsive ── */
@media (max-width: 1000px) {
    .category-nav { display: none; }
    .main-layout { padding: 16px; }
}
@media (max-width: 600px) {
    .header-inner { flex-wrap: wrap; height: auto; padding: 10px 0; }
    .header-stats { display: none; }
    .item-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}
