/* ============================================================
   styles.css – Lucas IMA Project
   ============================================================ */

/* ---------- Reset & Basis ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:        #2563eb;
  --primary-dark:   #1d4ed8;
  --primary-light:  #dbeafe;
  --secondary:      #7c3aed;
  --success:        #16a34a;
  --success-light:  #dcfce7;
  --danger:         #dc2626;
  --danger-light:   #fee2e2;
  --warning:        #d97706;
  --warning-light:  #fef3c7;
  --bg:             #f1f5f9;
  --surface:        #ffffff;
  --border:         #e2e8f0;
  --text:           #0f172a;
  --text-muted:     #64748b;
  --radius:         12px;
  --radius-sm:      8px;
  --shadow:         0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:      0 4px 12px rgba(0,0,0,.10);
  --shadow-lg:      0 10px 30px rgba(0,0,0,.14);
  --transition:     .2s ease;
  --sidebar-w:      240px;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---------- App Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

/* ---------- Sidebar Overlay (Mobile) ---------- */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(2px);
  z-index: 199;
}
.sidebar-overlay.active { display: block; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0;
  height: 100%;
  z-index: 200;
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  will-change: transform;
}
.sidebar-brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-brand-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px; font-weight: 700;
}
.sidebar-brand-text { font-weight: 700; font-size: 15px; line-height: 1.2; }
.sidebar-brand-sub  { font-size: 11px; color: var(--text-muted); font-weight: 400; }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.sidebar-section { padding: 8px 14px 4px; font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; }
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px;
  font-size: 13.5px; font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 8px;
  margin: 1px 8px;
  transition: background var(--transition), color var(--transition);
}
.sidebar-link:hover,
.sidebar-link.active { background: var(--primary-light); color: var(--primary); }
.sidebar-link .icon { font-size: 16px; width: 20px; text-align: center; }

/* ---------- Main Wrap ---------- */
.main-wrap {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 64px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow);
}
.topbar-menu-btn {
  background: none; border: none; cursor: pointer;
  font-size: 22px; padding: 8px;
  color: var(--text);
  border-radius: 8px;
  line-height: 1;
  min-width: 44px; min-height: 44px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition);
}
.topbar-menu-btn:hover { background: var(--bg); }
.topbar-title {
  font-size: 17px; font-weight: 700; flex: 1;
}
.topbar-subtitle { font-weight: 400; color: var(--text-muted); font-size: 13px; }

/* ---------- Page Content ---------- */
.page-content { flex: 1; padding: 28px 28px 48px; max-width: 1100px; width: 100%; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}
.page-header { margin-bottom: 22px; }
.page-header h2 { font-size: 19px; font-weight: 700; }
.page-header p  { font-size: 14px; color: var(--text-muted); margin-top: 3px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px;
  border: none; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary   { background: var(--primary);   color: #fff; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(37,99,235,.3); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-success   { background: var(--success);   color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger    { background: var(--danger);    color: #fff; }
.btn-danger:hover  { background: #b91c1c; }
.btn-lg { padding: 16px 28px; font-size: 16px; border-radius: var(--radius); }
.btn-icon { font-size: 22px; }

/* ---------- Erfassungs-Buttons (große Kacheln) ---------- */
.capture-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 8px;
}
.capture-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 44px 24px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  text-align: center;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  text-decoration: none;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.capture-btn:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light), var(--shadow-md);
  transform: translateY(-3px);
}
.capture-btn:active { transform: scale(.97); }
.capture-btn.qr-btn:hover  { border-color: var(--primary); }
.capture-btn.man-btn:hover { border-color: var(--secondary); }
.capture-btn .cb-icon {
  width: 88px; height: 88px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 40px;
}
.qr-btn  .cb-icon { background: var(--primary-light); }
.man-btn .cb-icon { background: #ede9fe; }
.capture-btn .cb-title { font-size: 18px; font-weight: 700; }
.capture-btn .cb-sub   { font-size: 13px; color: var(--text-muted); line-height: 1.4; max-width: 200px; }

/* ---------- Scanner Modal ---------- */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15,23,42,.70);
  backdrop-filter: blur(5px);
  z-index: 500;
  align-items: center; justify-content: center;
  padding: 16px;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 600px;
  max-height: 95dvh;
  overflow-y: auto;
  animation: slideUp .25s ease;
}
@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0;
  background: var(--surface);
  z-index: 10;
}
.modal-header h3 { flex: 1; font-size: 17px; font-weight: 700; }
.modal-close {
  background: none; border: none;
  font-size: 26px; cursor: pointer;
  color: var(--text-muted); line-height: 1;
  border-radius: 8px; padding: 4px 8px;
  min-width: 44px; min-height: 44px;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 18px 24px;
  border-top: 1px solid var(--border);
  display: flex; gap: 12px; justify-content: flex-end;
  flex-wrap: wrap;
  position: sticky; bottom: 0;
  background: var(--surface);
}

/* ---------- Tap-to-Focus ---------- */
.focus-ring {
  position: absolute;
  width: 70px; height: 70px;
  border: 2px solid #fff;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%) scale(1.4);
  transition: opacity .15s ease, transform .25s ease;
  box-shadow: 0 0 0 1px rgba(0,0,0,.4);
  z-index: 20;
}
.focus-ring::before,
.focus-ring::after {
  content: '';
  position: absolute;
  background: #fff;
}
.focus-ring::before { top: 50%; left: -10px; right: -10px; height: 1px; transform: translateY(-50%); }
.focus-ring::after  { left: 50%; top: -10px; bottom: -10px; width: 1px; transform: translateX(-50%); }
.focus-ring.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.focus-ring.focused {
  border-color: #facc15;
  box-shadow: 0 0 0 1px rgba(0,0,0,.4), 0 0 8px rgba(250,204,21,.6);
}
.focus-ring.focused::before,
.focus-ring.focused::after { background: #facc15; }

.tap-hint {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 20px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 1;
  transition: opacity .5s ease;
  z-index: 20;
}
.tap-hint.hidden { opacity: 0; }

/* ---------- Scanner Box ---------- */
.scanner-box {
  position: relative;
  background: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 4/3;
  margin-bottom: 14px;
  min-height: 220px;
}
.scanner-box video { width: 100%; height: 100%; object-fit: cover; display: block; transform: translateZ(0); }
.scanner-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.scanner-frame {
  width: 75%; aspect-ratio: 3/1;
  border: 3px solid var(--primary);
  border-radius: 10px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.4);
  position: relative;
}
.scanner-frame::before, .scanner-frame::after,
.scanner-frame .c::before, .scanner-frame .c::after {
  content: ''; position: absolute;
  width: 22px; height: 22px;
  border-color: #fff; border-style: solid;
}
.scanner-frame::before  { top: -3px; left: -3px; border-width: 3px 0 0 3px; border-radius: 4px 0 0 0; }
.scanner-frame::after   { top: -3px; right: -3px; border-width: 3px 3px 0 0; border-radius: 0 4px 0 0; }
.scanner-frame .c::before { bottom: -3px; left: -3px; border-width: 0 0 3px 3px; border-radius: 0 0 0 4px; }
.scanner-frame .c::after  { bottom: -3px; right: -3px; border-width: 0 3px 3px 0; border-radius: 0 0 4px 0; }
.scan-line {
  position: absolute; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, #3b82f6, transparent);
  animation: scanAnim 2s ease-in-out infinite;
}
@keyframes scanAnim {
  0%   { top: 10%; }
  50%  { top: 85%; }
  100% { top: 10%; }
}
.scanner-status {
  text-align: center;
  font-size: 14px; color: var(--text-muted);
  padding: 8px 0 12px;
  font-weight: 500;
}
.scanner-status.detected { color: var(--success); font-weight: 700; }

/* ---------- Form ---------- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { font-size: 14px; font-weight: 600; color: var(--text); }
.form-group label span { font-weight: 400; color: var(--text-muted); }
.form-group input,
.form-group select,
.form-group textarea {
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px; font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  resize: vertical;
  min-height: 44px;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.form-group input.success { border-color: var(--success); background: var(--success-light); }

/* ---------- Alert ---------- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500;
  margin-bottom: 20px;
  display: flex; align-items: center; gap: 8px;
}
.alert.success { background: var(--success-light); color: var(--success); border: 1px solid #86efac; }
.alert.error   { background: var(--danger-light);  color: var(--danger);  border: 1px solid #fca5a5; }
.alert.info    { background: var(--primary-light); color: var(--primary); border: 1px solid #93c5fd; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  background: var(--bg);
  padding: 11px 14px;
  text-align: left; font-size: 12px; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

/* ---------- Badge ---------- */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
}
.badge-neu           { background: var(--primary-light); color: var(--primary); }
.badge-in_bearbeitung{ background: var(--warning-light); color: var(--warning); }
.badge-abgeschlossen { background: var(--success-light); color: var(--success); }
.badge-verworfen     { background: var(--danger-light);  color: var(--danger);  }

/* ---------- Spinner ---------- */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid #fff3;
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: none;
}
.spinner.active { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Toast ---------- */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--text);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn .3s ease;
  display: flex; align-items: center; gap: 8px;
  max-width: 340px;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ---------- Responsive ---------- */

/* Tablet & Mobile: Sidebar wird zum Hamburger-Drawer */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    width: 280px;
    transform: translateX(-100%);
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .main-wrap { margin-left: 0; }

  .topbar { padding: 0 16px; height: 60px; }
  .topbar-title { font-size: 15px; }
  .topbar-subtitle { display: none; }

  .page-content { padding: 18px 16px 40px; }

  .capture-grid { gap: 16px; }
  .capture-btn { padding: 32px 16px; gap: 12px; }
  .capture-btn .cb-icon { width: 72px; height: 72px; font-size: 32px; }
  .capture-btn .cb-title { font-size: 16px; }
  .capture-btn .cb-sub { font-size: 12px; }
}

/* Handy Hochformat */
@media (max-width: 600px) {
  .capture-grid { grid-template-columns: 1fr; gap: 14px; }

  .capture-btn { padding: 28px 20px; flex-direction: row; text-align: left; gap: 18px; justify-content: flex-start; }
  .capture-btn .cb-icon { width: 64px; height: 64px; font-size: 28px; flex-shrink: 0; }
  .capture-btn .cb-sub  { display: block; }

  .form-grid { grid-template-columns: 1fr; }

  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    max-width: 100%;
    border-radius: var(--radius) var(--radius) 0 0;
    max-height: 96dvh;
  }

  .modal-footer { flex-direction: column; }
  .modal-footer .btn { width: 100%; justify-content: center; padding: 14px; font-size: 15px; }

  .topbar { padding: 0 12px; }
  .page-content { padding: 14px 12px 36px; }
  .card { padding: 18px 16px; }
}

/* Sehr kleine Displays */
@media (max-width: 360px) {
  .capture-btn .cb-icon { width: 52px; height: 52px; font-size: 24px; }
  .capture-btn .cb-title { font-size: 14px; }
}
