/* =========================================================
   UsedChiller Registrator – App Stylesheet
   Mobile-first, dark/light mode
   Palette: Slate dark + Blue accent (professional)
   ========================================================= */

:root {
  --accent: #3b82f6;       /* Blue-500 */
  --accent-dark: #2563eb;  /* Blue-600 */
  --accent-muted: rgba(59,130,246,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.18s ease;
  --shadow: 0 2px 16px rgba(0,0,0,0.28);
}

/* --- Dark mode (default) --- */
[data-theme="dark"], :root {
  --bg: #0f172a;       /* Slate-900 */
  --bg2: #1e293b;      /* Slate-800 */
  --bg3: #293548;      /* between 700/800 */
  --card: #1e293b;
  --border: #334155;   /* Slate-700 */
  --text: #f1f5f9;     /* Slate-100 */
  --text2: #94a3b8;    /* Slate-400 */
  --input-bg: #293548;
  --input-border: #475569; /* Slate-600 */
  --btn-text: #ffffff;
  --danger: #f87171;
  --danger-bg: rgba(248,113,113,0.12);
  --success: #34d399;
}

[data-theme="light"] {
  --bg: #f1f5f9;       /* Slate-100 */
  --bg2: #ffffff;
  --bg3: #e2e8f0;      /* Slate-200 */
  --card: #ffffff;
  --border: #cbd5e1;   /* Slate-300 */
  --text: #0f172a;     /* Slate-900 */
  --text2: #64748b;    /* Slate-500 */
  --input-bg: #ffffff;
  --input-border: #94a3b8; /* Slate-400 */
  --btn-text: #ffffff;
  --danger: #dc2626;
  --danger-bg: rgba(220,38,38,0.10);
  --success: #059669;
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* ---- Typography ---- */
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }

/* ---- Layout ---- */
#app { display: flex; flex-direction: column; min-height: 100dvh; }

.topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; height: 56px;
  background: var(--bg2); border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.topbar-logo {
  font-size: 1.1rem; font-weight: 800; color: var(--accent);
  letter-spacing: -0.5px;
}

.topbar-actions { display: flex; gap: 8px; align-items: center; }

.main { flex: 1; padding: 16px; max-width: 720px; margin: 0 auto; width: 100%; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: var(--radius);
  font-size: 0.9rem; font-weight: 600; cursor: pointer;
  border: none; transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: var(--btn-text); }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost {
  background: transparent; color: var(--text2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg3); color: var(--text); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-icon {
  padding: 8px; background: transparent; border: 1px solid var(--border);
  color: var(--text2); border-radius: var(--radius-sm);
}
.btn-icon:hover { color: var(--text); background: var(--bg3); }
.btn-full { width: 100%; }

/* ---- Card ---- */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow);
}

/* ---- Form elements ---- */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }

label.form-label {
  font-size: 0.85rem; font-weight: 600; color: var(--text2);
  text-transform: uppercase; letter-spacing: 0.04em;
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="email"],
select, textarea {
  width: 100%; padding: 12px 14px;
  background: var(--input-bg); border: 1.5px solid var(--input-border);
  border-radius: var(--radius); color: var(--text);
  font-size: 1rem; font-family: inherit;
  transition: border-color var(--transition);
  -webkit-appearance: none; appearance: none;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}
input::placeholder, textarea::placeholder { color: var(--text2); opacity: 0.7; }

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239999bb' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

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

.hint { font-size: 0.78rem; color: var(--text2); margin-top: 2px; }

/* ---- Radio offer-type pills ---- */
.radio-group { display: flex; gap: 10px; }
.radio-pill input[type="radio"] { display: none; }
.radio-pill label {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 50px;
  border: 2px solid var(--border); cursor: pointer;
  font-weight: 600; font-size: 0.9rem;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.radio-pill label::before {
  content: ""; width: 18px; height: 18px;
  border-radius: 50%; border: 2px solid var(--border);
  transition: all var(--transition);
  flex-shrink: 0;
}
.radio-pill input:checked + label {
  border-color: var(--accent); color: var(--accent);
}
.radio-pill input:checked + label::before {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: inset 0 0 0 3px var(--card);
}

/* ---- Photo upload area ---- */
.photo-upload-area {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 24px 16px; text-align: center;
  cursor: pointer; transition: border-color var(--transition);
  background: var(--bg3);
}
.photo-upload-area:hover, .photo-upload-area.drag-over {
  border-color: var(--accent);
}
.photo-upload-area .upload-icon { font-size: 2rem; margin-bottom: 8px; }
.photo-upload-area p { color: var(--text2); font-size: 0.9rem; }
.photo-upload-area strong { color: var(--accent); }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px; margin-top: 12px;
}
.photo-thumb {
  position: relative; aspect-ratio: 1;
  border-radius: var(--radius-sm); overflow: hidden;
  background: var(--bg3);
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-thumb .remove-btn {
  position: absolute; top: 4px; right: 4px;
  background: rgba(0,0,0,0.7); color: #fff;
  border: none; border-radius: 50%; width: 22px; height: 22px;
  font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}

/* ---- Category chips ---- */
.category-hint { color: var(--accent); font-weight: 600; font-size: 0.9rem; cursor: pointer; }

/* ---- Listing cards ---- */
.listing-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  transition: border-color var(--transition);
  cursor: pointer;
}
.listing-card:hover { border-color: var(--accent); }
.listing-card:active { transform: scale(0.99); }

.listing-img {
  width: 100%; aspect-ratio: 16/9; object-fit: cover;
  background: var(--bg3);
}
.listing-img-placeholder {
  width: 100%; aspect-ratio: 16/9;
  background: var(--bg3); display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem; color: var(--text2);
}

.listing-body { padding: 12px; }
.listing-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 50px;
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-biete { background: var(--accent-muted); color: var(--accent); }
.badge-suche { background: rgba(99,102,241,0.15); color: #818cf8; }
.badge-cat { background: var(--bg3); color: var(--text2); border: 1px solid var(--border); }

.listing-title { font-weight: 700; font-size: 0.95rem; line-height: 1.3; margin-bottom: 4px; }
.listing-price { color: var(--accent); font-weight: 700; font-size: 0.95rem; }
.listing-date { font-size: 0.75rem; color: var(--text2); }

/* ---- Filter bar ---- */
.filter-bar {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px;
}
.filter-chip {
  padding: 6px 12px; border-radius: 50px;
  border: 1.5px solid var(--border); background: var(--bg2);
  font-size: 0.8rem; font-weight: 600; color: var(--text2);
  cursor: pointer; transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.filter-chip.active { border-color: var(--accent); color: var(--accent); background: var(--accent-muted); }

/* ---- PWA Install Banner ---- */
.install-banner {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg2); border: 1px solid var(--accent);
  border-radius: var(--radius); padding: 12px 14px;
  margin-bottom: 16px;
  animation: slideUp 0.25s ease;
}
.install-banner-ios {
  border-color: var(--border);
  background: var(--bg3);
}
.install-banner-icon {
  font-size: 28px; color: var(--accent); flex-shrink: 0;
}
.install-banner-text {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
  font-size: 0.85rem; color: var(--text2); line-height: 1.4;
}
.install-banner-text strong:first-child {
  font-size: 0.92rem; color: var(--text); font-weight: 700;
}

/* ---- Search ---- */
.search-wrap { position: relative; margin-bottom: 20px; width: 100%; }
.search-wrap input[type="search"] {
  display: block;
  width: 100%;
  padding-left: 44px;
  padding-right: 16px;
  border-radius: 50px;
  height: 48px;
  background: var(--bg2);
  border-color: var(--border);
  font-size: 1rem;
  -webkit-appearance: none;
  appearance: none;
}
.search-wrap input[type="search"]::-webkit-search-cancel-button { display: none; }
.search-wrap input[type="search"]:focus { border-color: var(--accent); }
.search-icon {
  position: absolute; left: 15px; top: 50%; transform: translateY(-50%);
  color: var(--text2); font-size: 1.05rem; pointer-events: none; user-select: none;
  line-height: 1;
}

/* ---- Topbar dropdown menu ---- */
.topbar-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  min-width: 180px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  z-index: 200; padding: 6px;
  animation: dropdownIn 0.15s ease;
}
@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.dropdown-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 10px 12px;
  border-radius: var(--radius-sm); border: none;
  background: transparent; color: var(--text);
  font-size: 0.9rem; font-weight: 500; cursor: pointer;
  text-align: left; transition: background var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.dropdown-item:hover { background: var(--bg3); }
.dropdown-item-danger { color: var(--danger); }
.dropdown-item-danger:hover { background: var(--danger-bg); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ---- FAB ---- */
.fab {
  position: fixed; bottom: 24px; right: 20px;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: var(--btn-text);
  border: none; font-size: 1.6rem; font-weight: 300;
  box-shadow: 0 4px 20px rgba(59,130,246,0.45);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  z-index: 50;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.fab:hover { background: var(--accent-dark); transform: scale(1.08); }
.fab:active { transform: scale(0.94); }

/* ---- Modal / Drawer ---- */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  z-index: 200; display: flex; align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.overlay.center { align-items: center; }

.drawer {
  background: var(--bg2); border-radius: var(--radius) var(--radius) 0 0;
  width: 100%; max-width: 720px; max-height: 92dvh;
  overflow-y: auto; padding: 20px 16px 32px;
  -webkit-overflow-scrolling: touch;
}
.drawer-handle {
  width: 36px; height: 4px; background: var(--border);
  border-radius: 2px; margin: 0 auto 16px;
}

.modal {
  background: var(--bg2); border-radius: var(--radius);
  width: calc(100% - 32px); max-width: 480px; max-height: 90dvh;
  overflow-y: auto; padding: 24px 20px;
}
.modal-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 20px; }

/* ---- Detail view ---- */
.detail-photos {
  display: flex; gap: 8px; overflow-x: auto;
  scroll-snap-type: x mandatory; margin: -16px -16px 16px;
  -webkit-overflow-scrolling: touch;
}
.detail-photos img {
  width: 100%; max-width: 100%; flex-shrink: 0;
  scroll-snap-align: start; border-radius: 0;
  object-fit: cover; max-height: 280px;
}
.detail-photos::-webkit-scrollbar { display: none; }

.detail-field { margin-bottom: 12px; }
.detail-field dt { font-size: 0.78rem; color: var(--text2); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.detail-field dd { font-size: 0.95rem; color: var(--text); }

/* ---- Auth ---- */
.auth-wrap {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 24px 16px; background: var(--bg);
}
.auth-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px 24px;
  width: 100%; max-width: 380px;
  box-shadow: var(--shadow);
}
.auth-logo { font-size: 1.4rem; font-weight: 800; color: var(--accent); margin-bottom: 6px; }

/* ---- Toast ---- */
.toast-wrap {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  z-index: 999; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: 90%; max-width: 400px;
}
.toast {
  padding: 10px 18px; border-radius: var(--radius);
  font-size: 0.88rem; font-weight: 600;
  background: var(--bg2); border: 1px solid var(--border);
  box-shadow: var(--shadow); color: var(--text);
  pointer-events: auto; animation: slideUp 0.3s ease;
}
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error { border-color: var(--danger); color: var(--danger); }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Loading spinner ---- */
.spinner {
  width: 24px; height: 24px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Empty state ---- */
.empty-state { text-align: center; padding: 48px 16px; color: var(--text2); }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }

/* ---- Divider ---- */
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ---- Section title ---- */
.section-title {
  font-size: 0.75rem; font-weight: 700; color: var(--text2);
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 12px;
}

/* ---- Admin user list ---- */
.user-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.user-row:last-child { border-bottom: none; }

/* ---- Listings grid: always a grid with gap ---- */
.listings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

/* ---- Responsive: tablet+ ---- */
@media (min-width: 600px) {
  .listings-grid {
    grid-template-columns: repeat(2, 1fr); gap: 16px;
  }
  .overlay { align-items: center; }
  .drawer {
    border-radius: var(--radius); margin: 0; max-height: 90dvh;
    max-width: 680px;
  }
}

/* ---- iOS safe area ---- */
.topbar { padding-top: env(safe-area-inset-top); height: calc(56px + env(safe-area-inset-top)); }
.fab { bottom: calc(24px + env(safe-area-inset-bottom)); right: calc(20px + env(safe-area-inset-right)); }
.toast-wrap { bottom: calc(90px + env(safe-area-inset-bottom)); }

/* ---- Smooth transitions for theme ---- */
body, .card, .topbar, .drawer, .modal, input, select, textarea {
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

/* ---- [x-cloak] hide before Alpine init ---- */
[x-cloak] { display: none !important; }

/* ---- OneDrive view ---- */
.od-connect-box {
  text-align: center;
  padding: 48px 20px;
}
.od-connect-box h3 {
  margin-bottom: 8px;
  font-size: 1.2rem;
}
.od-connect-box p {
  color: var(--text2);
  margin-bottom: 20px;
  font-size: 0.9rem;
}
.od-account-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
}
.od-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.od-breadcrumb {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  min-width: 120px;
  overflow-x: auto;
  white-space: nowrap;
  padding: 4px 0;
}
.od-breadcrumb-item {
  color: var(--accent);
  cursor: pointer;
  font-size: 0.9rem;
  white-space: nowrap;
}
.od-breadcrumb-item:hover { text-decoration: underline; }
.od-breadcrumb-sep { color: var(--text2); }
.od-file-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.od-file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--card);
  transition: background 0.15s;
  min-width: 0;
}
.od-file-item:hover { background: var(--surface); }
.od-file-item-folder { color: #f59e0b; }
.od-file-item-name {
  flex: 1;
  font-size: 0.92rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.od-file-meta {
  font-size: 0.78rem;
  color: var(--text2);
  white-space: nowrap;
}
