/* ============================================================
   FMM – Filament Manager · Haupt-CSS
   Dark-First Design · Light Mode per Klasse .light
   ============================================================ */

:root {
  --bg:          #1a1a1a;
  --bg-card:     #222222;
  --bg-card2:    #222222;
  --bg-input:    #2a2a2a;
  --border:      #333333;
  --border-light:#444444;
  --text:        #e8e8e8;
  --text-muted:  #888888;
  --text-dim:    #555555;
  --accent:      #f57c00;
  --accent-dim:  #7a3e00;
  --accent-bg:   #1f1200;
  --success:     #4caf50;
  --success-bg:  #0a1f0a;
  --danger:      #f44336;
  --danger-bg:   #1f0a0a;
  --warning:     #ff9800;
  --warning-bg:  #1f1500;
  --info:        #2196f3;
  --info-bg:     #0a1525;
  --sidebar-w:   240px;
  --topbar-h:    56px;
  --radius:      8px;
  --radius-lg:   12px;
  --shadow:      0 2px 8px rgba(0,0,0,0.4);
  --transition:  0.2s ease;
  --font:        'Inter', 'Segoe UI', system-ui, sans-serif;
}

/* ---- Light Mode ---- */
.light {
  --bg:          #e0e0e0;
  --bg-card:     #ffffff;
  --bg-card2:    #f8f8f8;
  --bg-input:    #ffffff;
  --border:      #e0e0e0;
  --border-light:#eeeeee;
  --text:        #1a1a1a;
  --text-muted:  #666666;
  --text-dim:    #aaaaaa;
  --accent-bg:   #fff3e0;
  --accent-dim:  #e65100;
  --success-bg:  #e8f5e9;
  --danger-bg:   #ffebee;
  --warning-bg:  #fff8e1;
  --info-bg:     #e3f2fd;
  --shadow:      0 2px 8px rgba(0,0,0,0.08);
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  transition: background var(--transition), color var(--transition);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

/* ============================================================
   Layout
   ============================================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition), background var(--transition);
}

.sidebar-logo {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo .logo-icon {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}

.sidebar-logo .logo-text {
  font-size: 16px; font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
}

.sidebar-logo .logo-sub {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.sidebar-nav { flex: 1; padding: 0.75rem 0; overflow-y: auto; }

.nav-section {
  padding: 0.5rem 1rem 0.25rem;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.6rem 1rem;
  margin: 1px 0.5rem;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  border: none;
  background: none;
  width: calc(100% - 1rem);
  text-align: left;
}

.nav-item:hover {
  background: var(--bg-card2);
  color: var(--text);
  text-decoration: none;
}

.nav-item.active {
  background: var(--accent-bg);
  color: var(--accent);
}

.nav-item .nav-icon {
  font-size: 18px;
  width: 20px;
  flex-shrink: 0;
  text-align: center;
}

.nav-item .nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--border);
}

/* ---- Main Content ---- */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---- Topbar ---- */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 50;
  transition: background var(--transition);
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ---- Page Content ---- */
.page-content {
  padding: 1.5rem;
  flex: 1;
}

/* ============================================================
   Karten
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  transition: background var(--transition), border-color var(--transition);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 1rem;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .icon { font-size: 18px; }

/* ============================================================
   Slot-Karten (Dashboard)
   ============================================================ */
.slots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.slot-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
  transition: all var(--transition);
}

.slot-card:hover { border-color: var(--border-light); }

.slot-card.active { border-color: var(--accent-dim); }

.slot-card .slot-color-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.slot-card .slot-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.slot-number {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.slot-status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
}
.slot-status-dot.online { background: var(--success); }
.slot-status-dot.empty  { background: var(--text-dim); }

.slot-material {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 2px;
}

.slot-color-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.75rem;
}

.slot-empty-label {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
}

.slot-stats {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.slot-stat { flex: 1; }
.slot-stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.slot-stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Fortschrittsbalken */
.progress-bar {
  height: 6px;
  background: var(--bg-card2);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* Farbkreis */
.color-swatch {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.15);
  display: inline-block;
  flex-shrink: 0;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  font-family: var(--font);
}

.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { opacity: 0.9; }

.btn-secondary {
  background: var(--bg-card2);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--border-light); background: var(--bg-input); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-card2); color: var(--text); }

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-sm { padding: 0.3rem 0.7rem; font-size: 12px; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 15px; }
.btn-icon { padding: 0.5rem; }
.btn-full { width: 100%; justify-content: center; }

/* ============================================================
   Formulare
   ============================================================ */
.form-group { margin-bottom: 1rem; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.form-control {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  transition: border-color var(--transition);
  outline: none;
}

.form-control:focus { border-color: var(--accent); }
.form-control::placeholder { color: var(--text-dim); }

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

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

.form-hint { font-size: 12px; color: var(--text-dim); margin-top: 0.25rem; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 0.25rem; }

.input-group {
  display: flex;
  gap: 0;
}
.input-group .form-control { border-radius: var(--radius) 0 0 var(--radius); }
.input-group .btn { border-radius: 0 var(--radius) var(--radius) 0; border-left: none; }

/* Color Picker */
.color-picker-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.color-picker-group input[type="color"] {
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  cursor: pointer;
  padding: 2px;
}

/* ============================================================
   Tabellen
   ============================================================ */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

table.fmm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.fmm-table thead th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--bg-card2);
  border-bottom: 1px solid var(--border);
}

.fmm-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.fmm-table tbody tr:last-child { border-bottom: none; }
.fmm-table tbody tr:hover { background: var(--bg-card2); }

.fmm-table td {
  padding: 0.75rem 1rem;
  color: var(--text);
  vertical-align: middle;
}

/* ============================================================
   Badges / Status
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-new      { background: var(--info-bg);    color: var(--info);    }
.badge-active   { background: var(--success-bg); color: var(--success); }
.badge-used     { background: var(--warning-bg); color: var(--warning); }
.badge-depleted { background: var(--bg-card2);   color: var(--text-dim);}
.badge-scrapped { background: var(--danger-bg);  color: var(--danger);  }
.badge-sold     { background: var(--accent-bg);  color: var(--accent);  }

/* ============================================================
   Modals
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(10px);
  transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-body  { padding: 1.25rem; }
.modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* ============================================================
   Toast Benachrichtigungen
   ============================================================ */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 280px;
  box-shadow: var(--shadow);
  animation: slideIn 0.2s ease;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger);  }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info    { border-left: 3px solid var(--info);    }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ============================================================
   Statistik-Kacheln
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
}

.stat-tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
}

.stat-tile-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-tile-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-tile-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ============================================================
   Drucker-Status Widget
   ============================================================ */
.printer-status {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card2);
  border-radius: var(--radius);
  font-size: 13px;
}

.printer-status .status-indicator {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.printer-status.printing .status-indicator {
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
  animation: pulse 2s infinite;
}
.printer-status.idle .status-indicator { background: var(--text-dim); }
.printer-status.offline .status-indicator { background: var(--danger); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ============================================================
   Wiki
   ============================================================ */
.wiki-content {
  font-size: 15px;
  line-height: 1.8;
  color: var(--text);
}
.wiki-content h1, .wiki-content h2, .wiki-content h3 {
  margin: 1.5rem 0 0.5rem;
  font-weight: 600;
}
.wiki-content h1 { font-size: 22px; }
.wiki-content h2 { font-size: 18px; border-bottom: 1px solid var(--border); padding-bottom: 0.35rem; }
.wiki-content h3 { font-size: 16px; }
.wiki-content p  { margin-bottom: 0.85rem; }
.wiki-content code {
  background: var(--bg-card2);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 13px;
}
.wiki-content pre {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;
  margin: 1rem 0;
}
.wiki-content ul, .wiki-content ol { margin: 0.5rem 0 0.85rem 1.5rem; }
.wiki-content li { margin-bottom: 0.25rem; }
.wiki-content table { border-collapse: collapse; width: 100%; margin: 1rem 0; }
.wiki-content th, .wiki-content td { border: 1px solid var(--border); padding: 0.5rem 0.75rem; }
.wiki-content th { background: var(--bg-card2); }

/* ============================================================
   Login-Seite
   ============================================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 1rem;
}

.login-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 380px;
}

.login-logo {
  text-align: center;
  margin-bottom: 1.75rem;
}

.login-logo .logo-icon-lg {
  width: 52px; height: 52px;
  background: var(--accent);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 800; color: #fff;
  margin: 0 auto 0.75rem;
}

.login-logo h1 { font-size: 20px; font-weight: 700; }
.login-logo p  { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ============================================================
   Theme Toggle
   ============================================================ */
.theme-toggle {
  width: 36px; height: 36px;
  border-radius: var(--radius);
  background: var(--bg-card2);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 18px;
  transition: all var(--transition);
  color: var(--text-muted);
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-light); }

/* ============================================================
   Responsive / Mobile
   ============================================================ */
.hamburger {
  display: none;
  width: 36px; height: 36px;
  align-items: center; justify-content: center;
  cursor: pointer;
  border-radius: var(--radius);
  background: var(--bg-card2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 20px;
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,0.3);
  }
  .main-content { margin-left: 0; }
  .hamburger { display: flex; }
  .slots-grid { grid-template-columns: 1fr 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .slots-grid { grid-template-columns: 1fr; }
  .page-content { padding: 1rem; }
}

/* ============================================================
   Utility
   ============================================================ */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-xs { gap: 0.25rem; }
.gap-sm { gap: 0.5rem; }
.gap-md { gap: 1rem; }
.gap-lg { gap: 1.5rem; }
.mt-sm { margin-top: 0.5rem; }
.mt-md { margin-top: 1rem; }
.mt-lg { margin-top: 1.5rem; }
.mb-sm { margin-bottom: 0.5rem; }
.mb-md { margin-bottom: 1rem; }
.mb-lg { margin-bottom: 1.5rem; }
.text-muted   { color: var(--text-muted); }
.text-accent  { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.font-bold { font-weight: 600; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.hidden { display: none !important; }
.divider { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
.spinner {
  width: 20px; height: 20px;
  border: 2px 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 {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-dim);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 0.75rem; opacity: 0.4; }
.empty-state p { font-size: 14px; }
