/* ==================== Shared Marketplace & Events Styles ==================== */
:root {
  --mp-bg: #f5f5f5;
  --mp-card-bg: #fff;
  --mp-text: #333;
  --mp-text-secondary: #666;
  --mp-border: #e0e0e0;
  --mp-primary: #667eea;
  --mp-primary-dark: #764ba2;
  --mp-success: #43a047;
  --mp-orange: #ff6f00;
  --mp-danger: #e53935;
  --mp-radius: 12px;
  --mp-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.dark-mode {
  --mp-bg: #1a1a2e;
  --mp-card-bg: #16213e;
  --mp-text: #e0e0e0;
  --mp-text-secondary: #aaa;
  --mp-border: #2a2a4a;
  --mp-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--mp-bg);
  color: var(--mp-text);
  min-height: 100vh;
}

/* ==================== Header ==================== */
.mp-header {
  background: linear-gradient(135deg, var(--mp-primary) 0%, var(--mp-primary-dark) 100%);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}
.mp-header.events-header {
  background: linear-gradient(135deg, var(--mp-primary) 0%, var(--mp-primary-dark) 100%);
}
.dark-mode .mp-header {
  background: linear-gradient(135deg, #3a4a8a 0%, #4a2d6a 100%);
}
.mp-header h1 {
  font-size: 20px;
  flex: 1;
}
.mp-header a, .mp-header button {
  color: white;
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 6px 12px;
  border-radius: 8px;
  transition: background 0.2s;
}
.mp-header a:hover, .mp-header button:hover {
  background: rgba(255,255,255,0.15);
}
.mp-back-btn { font-size: 20px; padding: 4px 8px; }

/* ==================== Toolbar (Filters/Search) ==================== */
.mp-toolbar {
  padding: 12px 16px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--mp-card-bg);
  border-bottom: 1px solid var(--mp-border);
}
.mp-search {
  flex: 1;
  min-width: 150px;
  padding: 10px 14px;
  border: 1px solid var(--mp-border);
  border-radius: 10px;
  font-size: 14px;
  background: var(--mp-bg);
  color: var(--mp-text);
}
.mp-select {
  padding: 10px 14px;
  border: 1px solid var(--mp-border);
  border-radius: 10px;
  font-size: 14px;
  background: var(--mp-bg);
  color: var(--mp-text);
  min-width: 120px;
}

/* ==================== Grid ==================== */
.mp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  padding: 16px;
}
@media (max-width: 640px) {
  .mp-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; padding: 10px; }
}

/* ==================== Card ==================== */
.mp-card {
  background: var(--mp-card-bg);
  border-radius: var(--mp-radius);
  overflow: hidden;
  position: relative;
  box-shadow: var(--mp-shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
  text-decoration: none;
  color: var(--mp-text);
  display: block;
}
.mp-card-fav {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0,0,0,0.4);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  z-index: 2;
  transition: transform 0.2s;
  text-decoration: none;
}
.mp-card-fav:hover { transform: scale(1.15); }
.mp-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
}
.mp-card-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: var(--mp-border);
}
.mp-card-no-img {
  width: 100%;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--mp-border);
  font-size: 48px;
  opacity: 0.4;
}
.mp-card-body {
  padding: 12px;
}
.mp-card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mp-card-price {
  font-size: 17px;
  font-weight: 700;
  color: var(--mp-success);
}
.mp-card-price.gift { color: var(--mp-orange); }
.mp-card-meta {
  font-size: 12px;
  color: var(--mp-text-secondary);
  margin-top: 6px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.mp-card-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  background: var(--mp-primary);
  color: white;
}
.mp-card-badge.sold {
  background: var(--mp-danger);
}
.mp-card-badge.reserved {
  background: var(--mp-orange);
}

/* ==================== Detail Page ==================== */
.mp-detail {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px;
}
.mp-detail-images {
  position: relative;
  border-radius: var(--mp-radius);
  overflow: hidden;
  background: var(--mp-border);
  margin-bottom: 16px;
}
.mp-detail-images img {
  width: 100%;
  max-height: 450px;
  object-fit: contain;
  display: block;
  background: #000;
}
.mp-image-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.5);
  color: white;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mp-image-nav.prev { left: 8px; }
.mp-image-nav.next { right: 8px; }
.mp-image-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 8px 0;
}
.mp-image-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--mp-border);
  border: none; cursor: pointer;
}
.mp-image-dot.active { background: var(--mp-primary); }

.mp-detail-card {
  background: var(--mp-card-bg);
  border-radius: var(--mp-radius);
  padding: 20px;
  box-shadow: var(--mp-shadow);
  margin-bottom: 16px;
}
.mp-detail-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
}
.mp-detail-price {
  font-size: 24px;
  font-weight: 700;
  color: var(--mp-success);
  margin-bottom: 12px;
}
.mp-detail-info {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--mp-text-secondary);
}
.mp-detail-info span {
  display: flex;
  align-items: center;
  gap: 4px;
}
.mp-detail-desc {
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ==================== Seller Box ==================== */
.mp-seller-box {
  background: var(--mp-card-bg);
  border-radius: var(--mp-radius);
  padding: 16px;
  box-shadow: var(--mp-shadow);
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.mp-seller-name {
  font-weight: 600;
  font-size: 16px;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}
.mp-seller-avatar {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  image-rendering: pixelated;
}
.mp-share-box {
  margin-bottom: 16px;
}

/* Flohmarkt Chat */
.fm-chat-box {
  background: var(--mp-card-bg);
  border-radius: var(--mp-radius);
  padding: 16px;
  box-shadow: var(--mp-shadow);
  margin-bottom: 16px;
}
.fm-chat-title {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(128,128,128,0.2);
}
.fm-chat-messages {
  max-height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  padding: 4px 0;
}
.fm-chat-msg {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
}
.fm-chat-msg-mine {
  align-self: flex-end;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.fm-chat-msg-other {
  align-self: flex-start;
  background: rgba(128,128,128,0.15);
  border-bottom-left-radius: 4px;
}
.fm-chat-msg-text {
  word-break: break-word;
}
.fm-chat-msg-time {
  font-size: 10px;
  opacity: 0.6;
  text-align: right;
  margin-top: 2px;
}
.fm-chat-input-row {
  display: flex;
  gap: 8px;
}
.fm-chat-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 20px;
  border: 1px solid rgba(128,128,128,0.3);
  background: var(--mp-bg);
  color: inherit;
  font-size: 14px;
  outline: none;
}
.fm-chat-input:focus {
  border-color: #667eea;
}
.fm-chat-send {
  border-radius: 20px !important;
  padding: 10px 16px !important;
  white-space: nowrap;
}
.fm-chat-empty {
  text-align: center;
  padding: 20px;
  color: rgba(128,128,128,0.6);
  font-size: 14px;
}
/* Owner inbox */
.fm-inbox-item {
  border-bottom: 1px solid rgba(128,128,128,0.15);
  padding: 10px 0;
}
.fm-inbox-item:last-child { border-bottom: none; }
.fm-inbox-header {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.fm-inbox-header:hover { opacity: 0.8; }
.fm-inbox-badge {
  background: #ff4757;
  color: #fff;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
}
.fm-inbox-time {
  margin-left: auto;
  font-size: 12px;
  opacity: 0.5;
}
.fm-inbox-preview {
  font-size: 13px;
  opacity: 0.6;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fm-inbox-chat {
  margin-top: 10px;
}

/* Flohmarkt Inbox on Main Page */
/* Flohmarkt Toolbar (3 buttons) */
.fm-toolbar {
  padding: 8px 16px;
  display: flex;
  gap: 8px;
}
.fm-toolbar-btn {
  flex: 1;
  padding: 10px 6px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: var(--mp-radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.2s;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(102,126,234,0.3);
}
.fm-toolbar-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(102,126,234,0.4); }
.fm-toolbar-btn.active {
  background: linear-gradient(135deg, #7b8ff5 0%, #8e5fba 100%);
  color: white;
  box-shadow: 0 4px 14px rgba(102,126,234,0.5);
}
.dark-mode .fm-toolbar-btn {
  background: linear-gradient(135deg, #3a4a8a 0%, #4a2d6a 100%);
  box-shadow: 0 2px 8px rgba(58,74,138,0.3);
}
.dark-mode .fm-toolbar-btn:hover {
  box-shadow: 0 4px 14px rgba(58,74,138,0.4);
}
.dark-mode .fm-toolbar-btn.active {
  background: linear-gradient(135deg, #4e60a8 0%, #5e3d82 100%);
  box-shadow: 0 4px 14px rgba(58,74,138,0.5);
}
.fm-toolbar-btn .fm-inbox-badge {
  font-size: 10px;
  padding: 1px 5px;
}
.fm-toolbar-panel {
  padding: 0 16px;
  margin-bottom: 12px;
}
.fm-toolbar-panel .mp-card {
  margin-bottom: 8px;
}

.fm-inbox-section {
  padding: 0 16px;
  margin-bottom: 12px;
}
.fm-inbox-toggle {
  width: 100%;
  padding: 10px 16px;
  background: var(--mp-card-bg);
  border: 1px solid rgba(128,128,128,0.2);
  border-radius: var(--mp-radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  color: inherit;
}
.fm-inbox-toggle:hover { opacity: 0.8; }
.fm-inbox-list {
  background: var(--mp-card-bg);
  border-radius: var(--mp-radius);
  box-shadow: var(--mp-shadow);
  margin-top: 8px;
  overflow: hidden;
}
.fm-inbox-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid rgba(128,128,128,0.1);
}
.fm-inbox-entry:last-child { border-bottom: none; }
.fm-inbox-entry:hover { background: rgba(128,128,128,0.05); }
.fm-inbox-thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}
.fm-inbox-thumb-empty {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: rgba(128,128,128,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.fm-inbox-info { flex: 1; min-width: 0; }
.fm-inbox-entry-title {
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fm-inbox-entry-sub {
  font-size: 12px;
  opacity: 0.6;
  margin-top: 2px;
}

/* Floating Action Button */
.mp-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 50px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 4px 18px rgba(102,126,234,0.45);
  transition: transform 0.2s, box-shadow 0.2s;
  z-index: 100;
}
.mp-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(102,126,234,0.55);
}
.mp-fab:active { transform: translateY(0); }
.mp-fab-icon {
  font-size: 22px;
  line-height: 1;
}
.mp-fab-text {
  white-space: nowrap;
}
@media (max-width: 480px) {
  .mp-fab { bottom: 16px; right: 16px; padding: 12px 18px; font-size: 14px; }
}

.mp-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 10px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  text-decoration: none;
}
.mp-btn:hover { transform: translateY(-1px); }
.mp-btn-primary {
  background: linear-gradient(135deg, var(--mp-primary) 0%, var(--mp-primary-dark) 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(102,126,234,0.3);
}
.mp-btn-success {
  background: linear-gradient(135deg, var(--mp-success) 0%, #2e7d32 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(67,160,71,0.3);
}
.mp-btn-orange {
  background: linear-gradient(135deg, var(--mp-primary) 0%, var(--mp-primary-dark) 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(102,126,234,0.3);
}
.mp-btn-danger {
  background: var(--mp-danger);
  color: white;
}
.mp-btn-outline {
  background: none;
  border: 1px solid var(--mp-border);
  color: var(--mp-text);
}

/* ==================== Create/Edit Form ==================== */
.mp-form {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
}
.mp-form-card {
  background: var(--mp-card-bg);
  border-radius: var(--mp-radius);
  padding: 20px;
  box-shadow: var(--mp-shadow);
}
.mp-form-group {
  margin-bottom: 16px;
}
.mp-form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--mp-text-secondary);
}
.mp-form-group input,
.mp-form-group textarea,
.mp-form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--mp-border);
  border-radius: 10px;
  font-size: 14px;
  background: var(--mp-bg);
  color: var(--mp-text);
  font-family: inherit;
}
.mp-form-group textarea {
  min-height: 120px;
  resize: vertical;
}
.mp-form-row {
  display: flex;
  gap: 12px;
}
.mp-form-row .mp-form-group { flex: 1; }

/* Image upload preview */
.mp-image-upload {
  border: 2px dashed var(--mp-border);
  border-radius: var(--mp-radius);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
  color: var(--mp-text-secondary);
}
.mp-image-upload:hover { border-color: var(--mp-primary); }
.mp-image-upload input { display: none; }
.mp-image-previews {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.mp-image-preview {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 8px;
  overflow: hidden;
}
.mp-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.mp-image-preview .remove-img {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  background: rgba(0,0,0,0.6);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==================== Empty State ==================== */
.mp-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--mp-text-secondary);
}
.mp-empty-icon { font-size: 48px; margin-bottom: 12px; }
.mp-empty-text { font-size: 16px; }

/* ==================== Loading ==================== */
.mp-loading {
  text-align: center;
  padding: 40px;
  color: var(--mp-text-secondary);
}

/* ==================== Event-specific ==================== */
.mp-event-date {
  font-size: 14px;
  font-weight: 600;
  color: var(--mp-orange);
}
.mp-event-location {
  font-size: 13px;
  color: var(--mp-text-secondary);
}
.mp-participant-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}
.mp-participant-count {
  font-size: 13px;
  color: var(--mp-text-secondary);
}
.mp-participant-fill {
  flex: 1;
  height: 6px;
  background: var(--mp-border);
  border-radius: 3px;
  overflow: hidden;
}
.mp-participant-fill-bar {
  height: 100%;
  background: var(--mp-success);
  border-radius: 3px;
  transition: width 0.3s;
}

/* ==================== Login Prompt ==================== */
.mp-login-prompt {
  background: var(--mp-card-bg);
  border-radius: var(--mp-radius);
  padding: 20px;
  text-align: center;
  box-shadow: var(--mp-shadow);
  margin-bottom: 16px;
}
.mp-login-prompt p {
  margin-bottom: 12px;
  color: var(--mp-text-secondary);
}

/* ==================== Pagination ==================== */
.mp-pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 20px;
}
.mp-pagination button {
  padding: 8px 16px;
  border: 1px solid var(--mp-border);
  border-radius: 8px;
  background: var(--mp-card-bg);
  color: var(--mp-text);
  cursor: pointer;
  font-size: 14px;
}
.mp-pagination button.active {
  background: var(--mp-primary);
  color: white;
  border-color: var(--mp-primary);
}
.mp-pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ==================== Owner Actions ==================== */
.mp-owner-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}
