/* ═══════════════════════════════════════════════════════
   Rent-a-Resource – Modern UI System 2024
   ═══════════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────────── */
:root {
  --blue-50:  #eff6ff;
  --blue-100: #dbeafe;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --green-50:  #f0fdf4;
  --green-100: #dcfce7;
  --green-600: #16a34a;
  --green-700: #15803d;
  --amber-50:  #fffbeb;
  --amber-100: #fef3c7;
  --amber-500: #f59e0b;
  --amber-600: #d97706;
  --red-50:   #fef2f2;
  --red-100:  #fee2e2;
  --red-500:  #ef4444;
  --red-600:  #dc2626;
  --red-700:  #b91c1c;
  --purple-50:  #faf5ff;
  --purple-100: #f3e8ff;
  --purple-600: #9333ea;
  --gray-50:  #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --radius-sm: 0.375rem;
  --radius:    0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow:    0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.1);
  --shadow-md: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,.1), 0 8px 10px -6px rgba(0,0,0,.1);
  --shadow-xl: 0 25px 50px -12px rgba(0,0,0,.25);
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--gray-800);
  background: #f4f6f9;
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4,h5,h6,p { margin: 0; }
button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}
svg { display: block; flex-shrink: 0; }

/* ── Layout helpers ────────────────────────────────────── */
.h-full   { height: 100%; }
.h-screen { height: 100vh; }
.flex     { display: flex; }
.flex-col { flex-direction: column; }
.flex-1   { flex: 1 1 0%; }
.overflow-hidden  { overflow: hidden; }
.overflow-y-auto  { overflow-y: auto; }

/* Sizing used on SVG icons */
.w-4 { width: 1rem; }
.h-4 { height: 1rem; }
svg.w-4 { width: 1rem; height: 1rem; }
svg.w-5 { width: 1.25rem; height: 1.25rem; }
svg.w-6 { width: 1.5rem; height: 1.5rem; }
.bg-gray-50 { background: var(--gray-50); }

/* ── Layout ────────────────────────────────────────────── */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}
.app-main {
  flex: 1;
  overflow-y: auto;
  background: #f4f6f9;
}

/* ── Mobile Header (nur auf kleinen Screens) ───────────── */
.mobile-header {
  display: none; /* Desktop: versteckt */
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3.5rem;
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  z-index: 50;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  box-shadow: var(--shadow-sm);
}
.mobile-menu-btn {
  background: none; border: none; cursor: pointer;
  color: var(--gray-600); padding: 0.25rem;
  display: flex; align-items: center;
}

/* ── Mobile Overlay ────────────────────────────────────── */
.mobile-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(2px);
  z-index: 90;
}

/* ── Sidebar ───────────────────────────────────────────── */
.sidebar {
  width: 15rem;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  box-shadow: 1px 0 0 var(--gray-100);
  /* Mobile: off-canvas */
  transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
}

/* ── Mobile Responsive ─────────────────────────────────── */
@media (max-width: 768px) {
  /* Mobile Header einblenden */
  .mobile-header { display: flex; }

  /* App-Layout ohne Sidebar-Platz */
  .app-layout { display: block; height: 100vh; overflow: hidden; }

  /* Main bekommt Platz für den fixed Header */
  .app-main {
    height: 100vh;
    overflow-y: auto;
    padding-top: 3.5rem;
  }

  /* Sidebar: fixed overlay von links */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    width: 16rem;
    transform: translateX(-100%);
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }

  /* Seiten-Padding auf Mobile reduzieren */
  [x-show] > div[style*="padding:2rem"] {
    padding: 1rem !important;
  }
  .page-header { margin-bottom: 1rem; }
  .page-title  { font-size: 1.125rem; }

  /* Kalender auf Mobile */
  .cal-page { padding: 0.75rem !important; }
  .cal-cell { min-height: 3.25rem; padding: 0.2rem 0.1rem; }
  .cal-day-num { font-size: 0.625rem; width: 1.25rem; height: 1.25rem; margin-bottom: 0.1rem; }
  .cal-header-day { font-size: 0.6rem; padding: 0.375rem 0.1rem; }
  .cal-event .event-label { display: none; }
  .cal-event { padding: 0.1rem 0.2rem; gap: 0; justify-content: center; }
  .cal-event .status-dot { width: 0.4rem; height: 0.4rem; min-width: 0.4rem; }

  /* Stat-Cards auf Mobile: 1 Spalte */
  .stats-grid { grid-template-columns: 1fr !important; }
}

/* ── Nav items ─────────────────────────────────────────── */
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  user-select: none;
  transition: background 0.12s, color 0.12s;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: var(--blue-50); color: var(--blue-700); }
.nav-item.active {
  background: var(--blue-50);
  color: var(--blue-600);
  font-weight: 600;
}

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.25;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s, border-color 0.15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--blue-600);
  color: #fff;
  border-color: var(--blue-700);
  box-shadow: 0 1px 2px rgba(37,99,235,.3), inset 0 1px 0 rgba(255,255,255,.1);
}
.btn-primary:hover:not(:disabled) {
  background: var(--blue-700);
  box-shadow: 0 4px 8px rgba(37,99,235,.3);
}

.btn-secondary {
  background: #fff;
  color: var(--gray-700);
  border-color: var(--gray-300);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--gray-50);
  border-color: var(--gray-400);
}

.btn-success {
  background: var(--green-600);
  color: #fff;
  border-color: var(--green-700);
  box-shadow: 0 1px 2px rgba(22,163,74,.3);
}
.btn-success:hover:not(:disabled) {
  background: var(--green-700);
  box-shadow: 0 4px 8px rgba(22,163,74,.3);
}

.btn-danger {
  background: var(--red-600);
  color: #fff;
  border-color: var(--red-700);
  box-shadow: 0 1px 2px rgba(220,38,38,.3);
}
.btn-danger:hover:not(:disabled) {
  background: var(--red-700);
  box-shadow: 0 4px 8px rgba(220,38,38,.3);
}

.btn-amber {
  background: var(--amber-500);
  color: #fff;
  border-color: var(--amber-600);
  box-shadow: 0 1px 2px rgba(245,158,11,.3);
}
.btn-amber:hover:not(:disabled) {
  background: var(--amber-600);
  box-shadow: 0 4px 8px rgba(245,158,11,.3);
}

.btn-ghost {
  background: transparent;
  color: var(--gray-600);
  border-color: transparent;
  box-shadow: none;
  padding: 0.375rem 0.625rem;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--gray-100);
  color: var(--gray-900);
}

.btn-sm {
  padding: 0.3125rem 0.75rem;
  font-size: 0.8125rem;
}

.btn-icon {
  padding: 0.5rem;
  border-radius: var(--radius);
}

/* ── Forms ─────────────────────────────────────────────── */
.lbl {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 0.375rem;
  letter-spacing: -0.01em;
}

.inp {
  display: block;
  width: 100%;
  padding: 0.5625rem 0.75rem;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  color: var(--gray-900);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
}
.inp::placeholder { color: var(--gray-400); }
.inp:hover { border-color: var(--gray-300); }
.inp:focus {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
select.inp { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.5rem center; background-size: 1.25rem; padding-right: 2.25rem; }

/* ── Cards ─────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
}

.card-sm {
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  padding: 1rem 1.25rem;
}

/* Stat cards */
.stat-card {
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.stat-card.blue::before  { background: linear-gradient(90deg,#2563eb,#60a5fa); }
.stat-card.amber::before { background: linear-gradient(90deg,#f59e0b,#fbbf24); }
.stat-card.green::before { background: linear-gradient(90deg,#16a34a,#4ade80); }

/* Resource cards */
.resource-card {
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.resource-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--blue-200, #bfdbfe);
}

/* ── Badges ────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.badge::before {
  content: '';
  display: inline-block;
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 9999px;
  flex-shrink: 0;
}
.status-pending  { background: var(--amber-50);  color: #92400e; border: 1px solid #fde68a; }
.status-pending::before  { background: #f59e0b; }
.status-approved { background: var(--green-50);  color: #14532d; border: 1px solid #86efac; }
.status-approved::before { background: #22c55e; }
.status-rejected { background: var(--red-50);    color: #7f1d1d; border: 1px solid #fca5a5; }
.status-rejected::before { background: #ef4444; }
.status-cancelled{ background: var(--gray-100);  color: var(--gray-500); border: 1px solid var(--gray-300); }
.status-cancelled::before{ background: var(--gray-400); }

/* Category pill */
.cat-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--blue-50);
  color: var(--blue-700);
  border: 1px solid var(--blue-100);
}

/* ── Modals ────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15,23,42,.45);
  backdrop-filter: blur(4px);
}
.modal-box {
  background: #fff;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(0,0,0,.05);
  width: 100%;
  max-width: 28rem;
  padding: 1.75rem;
}
.modal-title {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 0.25rem;
}

/* ── Dividers ──────────────────────────────────────────── */
.divide-y > * + * { border-top: 1px solid var(--gray-100); }
.row { padding: 0.875rem 0; }
.row:last-child { border-bottom: none; }

/* ── Page header ───────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.page-title {
  font-size: 1.375rem;
  font-weight: 800;
  color: var(--gray-900);
  letter-spacing: -0.03em;
}

/* ── Animations ────────────────────────────────────────── */
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.8; transform: scale(1.08); }
}

/* ── Loader ────────────────────────────────────────────── */
#app-loader {
  position: fixed;
  inset: 0;
  background: #f4f6f9;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
#app-loader.done { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ─────────────────────────────────────────────── */
.toast {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 9999;
  max-width: 22rem;
  padding: 0.875rem 1.125rem;
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0,0,0,.05);
}

/* ── Utility ───────────────────────────────────────────── */
[x-cloak] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ── Calendar ──────────────────────────────────────────── */
.cal-header-day {
  padding: 0.625rem 0.5rem;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}
/* ── Kalender-Grid: fixe gleiche Spaltenbreite ─────────────
   Entscheidend: overflow:hidden auf der Zelle + min-width:0
   verhindert dass Inhalte die Zelle aufweiten.            */
.cal-grid-wrapper {
  width: 100%;
  overflow: hidden; /* verhindert horizontales Wachsen */
}
.cal-header-row,
.cal-body-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr)); /* minmax(0,1fr) = feste gleiche Breite */
  width: 100%;
}
.cal-cell {
  min-height: 6.5rem;
  max-width: 100%;       /* niemals breiter als 1/7 des Grids */
  overflow: hidden;      /* Inhalt abschneiden statt Zelle weiten */
  border-right: 1px solid var(--gray-100);
  border-bottom: 1px solid var(--gray-100);
  padding: 0.375rem;
  cursor: pointer;
  transition: background 0.1s;
  box-sizing: border-box;
}
.cal-cell:hover { background: var(--blue-50); }
.cal-cell.other-month { background: #fafafa; }
.cal-cell.today-cell  { background: #eff6ff; }

.cal-day-num {
  font-size: 0.8125rem;
  font-weight: 500;
  width: 1.625rem;
  height: 1.625rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  margin-bottom: 0.25rem;
  color: var(--gray-700);
  flex-shrink: 0;
}
.cal-day-num.is-today {
  background: var(--blue-600);
  color: #fff;
  font-weight: 700;
}
.cal-day-num.other-month { color: var(--gray-400); }

.cal-event {
  font-size: 0.65rem;
  line-height: 1.3;
  padding: 0.2rem 0.375rem;
  border-radius: 0.25rem;
  margin-bottom: 0.2rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  overflow: hidden;
  max-width: 100%;      /* niemals breiter als die Zelle */
}
.cal-event .status-dot {
  width: 0.5rem;
  height: 0.5rem;
  min-width: 0.5rem;    /* verhindert Schrumpfen */
  border-radius: 9999px;
  flex-shrink: 0;
  display: inline-block;
}
.cal-event .event-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

/* ── Kalender Responsive (Mobile) ──────────────────────── */
@media (max-width: 640px) {
  /* Kalender-Seite: volle Breite, kein seitliches Padding */
  .cal-page { padding: 1rem 0.5rem !important; }

  /* Kleinere Zellen auf Mobile */
  .cal-cell {
    min-height: 3.5rem;
    padding: 0.25rem 0.125rem;
  }
  .cal-day-num {
    font-size: 0.6875rem;
    width: 1.375rem;
    height: 1.375rem;
    margin-bottom: 0.125rem;
  }
  /* Events auf Mobile: nur Dot, kein Text */
  .cal-event .event-label { display: none; }
  .cal-event {
    padding: 0.125rem 0.25rem;
    gap: 0;
    justify-content: center;
    border-left-width: 2px;
  }
  .cal-event .status-dot {
    width: 0.4rem;
    height: 0.4rem;
    min-width: 0.4rem;
  }
  /* Wochentag-Header kürzer */
  .cal-header-day { font-size: 0.625rem; padding: 0.375rem 0.125rem; }
}

/* ── Filter Pills ──────────────────────────────────────── */
.filter-pill {
  padding: 0.375rem 0.875rem;
  border-radius: 9999px;
  font-size: 0.8125rem;
  font-weight: 600;
  border: 1.5px solid var(--gray-200);
  background: #fff;
  color: var(--gray-600);
  cursor: pointer;
  transition: all 0.12s;
  box-shadow: var(--shadow-xs);
}
.filter-pill:hover { border-color: var(--blue-500); color: var(--blue-600); }
.filter-pill.active {
  background: var(--blue-600);
  border-color: var(--blue-600);
  color: #fff;
  box-shadow: 0 2px 6px rgba(37,99,235,.35);
}

/* ── Section label ─────────────────────────────────────── */
.section-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-400);
  padding: 0.875rem 0.75rem 0.375rem;
}

/* ── Highlight card ────────────────────────────────────── */
.info-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
  font-weight: 500;
}
.info-box.warning {
  background: var(--amber-50);
  border: 1px solid #fde68a;
  color: #92400e;
}
