/* ═══════════════════════════════════════════════════════
   SesHuéspedes + ImmoS — Gemeinsames Design-System
   Default: light theme | [data-theme="dark"]: dark theme
   ═══════════════════════════════════════════════════════ */

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

:root {
  /* Brand */
  --primary:        #3d7a3d;
  --primary-hover:  #2d5e2d;
  --primary-light:  rgba(61,122,61,.15);
  --success:        #22c55e;
  --success-hover:  #16a34a;
  --warning:        #f59e0b;
  --error:          #ef4444;

  /* Surface — light (default) */
  --bg:             #f9fafb;
  --bg-2:           #f3f4f6;
  --card:           #ffffff;
  --card-2:         #f8fafc;
  --border:         #e5e7eb;

  /* Text */
  --text:           #111827;
  --text-muted:     #6b7280;
  --text-light:     #9ca3af;

  /* Elevation */
  --shadow:         0 1px 4px rgb(0 0 0/.08);
  --shadow-lg:      0 8px 24px rgb(0 0 0/.12);

  /* Radius */
  --r-sm:  0.375rem;
  --r-md:  0.5rem;
  --r-lg:  0.75rem;
  --r-xl:  1rem;

  /* Spacing */
  --gap:   1rem;
}

/* ── Base ──────────────────────────────────────────────── */

html, body {
  height: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  font-size: 15px;
}

/* ── Layout ────────────────────────────────────────────── */

.app-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 var(--gap);
}

.app-container--narrow { max-width: 700px; }
.app-container--wide   { max-width: 1400px; }

/* ── Header / Nav ──────────────────────────────────────── */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem var(--gap);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 50;
}

.app-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  letter-spacing: -.01em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
}

.nav-link {
  padding: 0.5rem 0.875rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--r-md);
  transition: color .15s, background .15s;
}

.nav-link:hover       { color: var(--text); background: var(--card-2); }
.nav-link.active      { color: var(--primary); background: var(--primary-light); }

/* Tab bar */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 49px;
  z-index: 49;
}

.tab-link {
  padding: 0.75rem 1.25rem 0.75rem 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}

.tab-link:hover  { color: var(--text); }
.tab-link.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Buttons ───────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, color .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
  user-select: none;
}

.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary   { background: var(--primary);  color: #fff; border-color: var(--primary); }
.btn-primary:hover:not(:disabled)  { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn-success   { background: var(--success);  color: #fff; border-color: var(--success); }
.btn-success:hover:not(:disabled)  { background: var(--success-hover); border-color: var(--success-hover); }

.btn-danger    { background: var(--error);    color: #fff; border-color: var(--error); }
.btn-danger:hover:not(:disabled)   { background: #dc2626; border-color: #dc2626; }

.btn-outline   { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover:not(:disabled)  { background: var(--card-2); border-color: var(--text-muted); }

.btn-ghost     { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover:not(:disabled)    { background: var(--card-2); color: var(--text); }

.btn-sm { padding: 0.3rem 0.625rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.75rem 1.5rem;  font-size: 1rem; }

/* ── Cards ─────────────────────────────────────────────── */

.card {
  background: var(--card);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
  font-weight: 600;
}

.card-body  { padding: 1rem; }
.card-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* ── Forms ─────────────────────────────────────────────── */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.75rem;
}

.form-group:last-child { margin-bottom: 0; }

label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-light);
}

input, select, textarea {
  width: 100%;
  padding: 0.5625rem 0.75rem;
  font-size: 0.9375rem;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: border-color .2s, box-shadow .2s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

input::placeholder, textarea::placeholder { color: var(--text-muted); }

select { cursor: pointer; }

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

input[type="checkbox"], input[type="radio"] {
  width: auto;
  accent-color: var(--primary);
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.form-error {
  font-size: 0.75rem;
  color: var(--error);
  margin-top: 0.2rem;
}

/* ── Table ─────────────────────────────────────────────── */

.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead th {
  padding: 0.625rem 0.75rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--card-2); }

tbody td {
  padding: 0.625rem 0.75rem;
  color: var(--text);
  vertical-align: middle;
}

/* ── Badges ────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 600;
  border-radius: 999px;
  letter-spacing: .03em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-green  { background: rgba(34,197,94,.15);  color: #22c55e; }
.badge-blue   { background: rgba(59,130,246,.15); color: #60a5fa; }
.badge-amber  { background: rgba(245,158,11,.15); color: #fbbf24; }
.badge-red    { background: rgba(239,68,68,.15);  color: #f87171; }
.badge-gray   { background: var(--card-2);        color: var(--text-muted); }

/* ── Alerts ────────────────────────────────────────────── */

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--r-md);
  font-size: 0.875rem;
  border: 1px solid;
}

.alert-success { background: #0a1a0a; border-color: #1a3a1a; color: #22c55e; }
.alert-error   { background: #1a0a0a; border-color: #3a1a1a; color: var(--error); }
.alert-warning { background: #1a1200; border-color: #3a2a00; color: var(--warning); }
.alert-info    { background: #0a0f1a; border-color: #1a2a3a; color: #60a5fa; }

/* ── Modal ─────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gap);
}

.modal {
  background: var(--card);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
}

.modal-title { font-size: 1rem; font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--r-sm);
  transition: background .15s, color .15s;
  line-height: 1;
}

.modal-close:hover { background: var(--border); color: var(--text); }

.modal-body   { padding: 1.25rem; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* ── Toast ─────────────────────────────────────────────── */

.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  padding: 0.75rem 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  max-width: 320px;
  animation: toast-in .2s ease;
}

.toast-success { border-left: 3px solid var(--success); }
.toast-error   { border-left: 3px solid var(--error); }
.toast-info    { border-left: 3px solid var(--primary); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Spinner ───────────────────────────────────────────── */

.spinner {
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Utilities ─────────────────────────────────────────── */

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-muted  { color: var(--text-muted); }
.text-sm     { font-size: 0.8125rem; }
.text-xs     { font-size: 0.75rem; }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.mono        { font-family: 'SF Mono', 'Fira Code', Menlo, monospace; }
.gap-sm      { gap: 0.5rem; }
.d-flex      { display: flex; }
.align-center { align-items: center; }
.flex-1      { flex: 1; }
.hidden      { display: none !important; }
.ci-hidden   { display: none !important; }
.divider { height: 1px; background: var(--border); margin: 1rem 0; }

/* ── Responsive ────────────────────────────────────────── */

@media (max-width: 768px) {
  body { font-size: 16px; }

  .app-container { padding: 0 0.75rem; }

  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal { border-radius: var(--r-xl) var(--r-xl) 0 0; max-width: none; max-height: 90vh; }

  .toast-container { bottom: 1rem; right: 0.75rem; left: 0.75rem; }
  .toast { max-width: none; }

  .tab-link { padding: 0.65rem 1rem 0.65rem 0; font-size: 0.9375rem; }
}

@media (max-width: 480px) {
  .btn-lg { padding: 0.625rem 1.25rem; font-size: 0.9375rem; }
}

@supports (padding: max(0px)) {
  .app-container { padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
}

@media (hover: none) and (pointer: coarse) {
  .btn:active:not(:disabled) { transform: scale(.97); opacity: .9; }
}

/* ── Dark Theme ────────────────────────────────────────── */

[data-theme="dark"] {
  --bg:         #000000;
  --bg-2:       #0a0a0a;
  --card:       #111111;
  --card-2:     #1a1a1e;
  --border:     #27272a;
  --text:       #e4e4e7;
  --text-muted: #71717a;
  --text-light: #a1a1aa;
  --shadow:     0 2px 8px rgb(0 0 0/.4);
  --shadow-lg:  0 8px 24px rgb(0 0 0/.5);
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: var(--bg-2);
  color: var(--text);
  border-color: var(--border);
}

[data-theme="dark"] .alert-success { background: #0a1a0a; border-color: #1a3a1a; }
[data-theme="dark"] .alert-error   { background: #1a0a0a; border-color: #3a1a1a; }
[data-theme="dark"] .alert-warning { background: #1a1200; border-color: #3a2a00; }
[data-theme="dark"] .alert-info    { background: #0a0f1a; border-color: #1a2a3a; }
