/* ============================================================
   JagdDigital Prüfungsverwaltung – Basis-Stylesheet
   ============================================================ */

:root {
  --primary: #2e7d32;
  --primary-dark: #1b5e20;
  --primary-light: #4caf50;
  --bg: #f5f5f5;
  --bg-white: #ffffff;
  --text: #212121;
  --text-light: #757575;
  --border: #e0e0e0;
  --error: #c62828;
  --error-bg: #ffebee;
  --success: #2e7d32;
  --success-bg: #e8f5e9;
  --radius: 6px;
  --shadow: 0 2px 4px rgba(0,0,0,0.1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

/* ============================================================
   Login-Seite
   ============================================================ */

.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

.login-box {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px;
  width: 100%;
  max-width: 400px;
}

.login-box h1 {
  font-size: 20px;
  margin-bottom: 4px;
  color: var(--primary-dark);
}

.login-box .subtitle {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 24px;
}

/* ============================================================
   Formulare
   ============================================================ */

.form-group {
  margin-bottom: 16px;
}

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

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  background: var(--bg-white);
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-block;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  width: 100%;
  padding: 10px;
  font-weight: 500;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-primary:disabled {
  background: var(--text-light);
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-danger {
  background: var(--error);
  color: #fff;
}

.btn-danger:hover {
  background: #b71c1c;
}

.btn-small {
  padding: 4px 10px;
  font-size: 12px;
}

/* ============================================================
   Meldungen
   ============================================================ */

.msg {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
  display: none;
}

.msg.error {
  background: var(--error-bg);
  color: var(--error);
  display: block;
}

.msg.success {
  background: var(--success-bg);
  color: var(--success);
  display: block;
}

/* ============================================================
   App-Layout
   ============================================================ */

.app-header {
  background: var(--primary-dark);
  color: #fff;
  padding: 0 20px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
}

.app-header .logo {
  font-size: 16px;
  font-weight: 600;
}

.app-header .user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

.app-header .user-info .role-badge {
  background: rgba(255,255,255,0.2);
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
}

.app-header .btn-logout {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: none;
  padding: 4px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
}

.app-header .btn-logout:hover {
  background: rgba(255,255,255,0.25);
}

/* ============================================================
   Navigation (Sidebar)
   ============================================================ */

.app-body {
  display: flex;
  min-height: calc(100vh - 48px);
}

.app-nav {
  width: 220px;
  background: var(--bg-white);
  border-right: 1px solid var(--border);
  padding: 12px 0;
  flex-shrink: 0;
}

.app-nav .nav-section {
  padding: 8px 16px 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-light);
  letter-spacing: 0.5px;
}

.app-nav .nav-item {
  display: block;
  padding: 8px 16px 8px 24px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.app-nav .nav-item:hover {
  background: var(--bg);
}

.app-nav .nav-item.active {
  background: var(--success-bg);
  color: var(--primary-dark);
  font-weight: 500;
}

/* ============================================================
   Content Area
   ============================================================ */

.app-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

.content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.content-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.content-header .btn {
  width: auto;
}

/* ============================================================
   Tabellen
   ============================================================ */

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.data-table th {
  background: var(--bg);
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-light);
  letter-spacing: 0.3px;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 10px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background: #fafafa;
}

.data-table th.sortable {
  cursor: pointer;
  user-select: none;
}

.data-table th.sortable:hover {
  color: var(--primary-dark);
}

/* ============================================================
   Table Filter
   ============================================================ */

.table-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.filter-input {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  width: 260px;
  transition: border-color 0.2s;
}

.filter-input:focus {
  outline: none;
  border-color: var(--primary);
}

.filter-count {
  font-size: 12px;
  color: var(--text-light);
}

/* ============================================================
   Modals
   ============================================================ */

.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  padding: 24px;
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal h3 {
  font-size: 16px;
  margin-bottom: 16px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* ============================================================
   Status-Badges
   ============================================================ */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
}

.badge-active {
  background: var(--success-bg);
  color: var(--success);
}

.badge-inactive {
  background: var(--error-bg);
  color: var(--error);
}

/* ============================================================
   Kontextmenü
   ============================================================ */

.ctx-menu {
  display: none;
  position: fixed;
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 2000;
  min-width: 160px;
  padding: 4px 0;
}

.ctx-menu.show {
  display: block;
}

.ctx-item {
  display: block;
  width: 100%;
  padding: 8px 14px;
  border: none;
  background: none;
  text-align: left;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

.ctx-item:hover {
  background: var(--bg);
}

.ctx-item.danger {
  color: var(--error);
}

.ctx-sep {
  border-top: 1px solid var(--border);
  margin: 4px 0;
}

.menu-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  padding: 0 4px;
  color: var(--text-light);
}

.menu-btn:hover {
  color: var(--text);
}

/* ============================================================
   Utilities
   ============================================================ */

.hidden {
  display: none !important;
}

.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-light);
}

/* ============================================================
   Form Row (nebeneinander)
   ============================================================ */

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group {
  flex: 1;
}

/* ============================================================
   Eigentümer-Suche
   ============================================================ */

.eigentuemer-display {
  padding: 6px 10px;
  min-height: 20px;
  border-radius: 4px;
  margin-bottom: 4px;
  font-size: 14px;
  color: var(--text-light);
}

.eigentuemer-display.selected {
  background: var(--bg-accent, #e8f4e8);
  color: var(--text-dark, #1a1a1a);
  cursor: pointer;
  border: 1px solid var(--border, #ccc);
}

.eigentuemer-display.selected::after {
  content: " ✕";
  color: #999;
  font-size: 12px;
}

.eigentuemer-results {
  display: none;
  position: absolute;
  z-index: 100;
  background: #fff;
  border: 1px solid var(--border, #ccc);
  border-radius: 4px;
  max-height: 200px;
  overflow-y: auto;
  width: calc(100% - 2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.eigentuemer-results.show {
  display: block;
}

.eigentuemer-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid #f0f0f0;
}

.eigentuemer-item:hover {
  background: var(--bg-accent, #e8f4e8);
}

.eigentuemer-item.disabled {
  color: #999;
  cursor: default;
}

.eigentuemer-item.disabled:hover {
  background: transparent;
}

#hundEigentuemerWrapper {
  position: relative;
}

/* ============================================================
   Form Hint
   ============================================================ */

.form-hint {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-light, #888);
}

/* ============================================================
   Checkbox Label
   ============================================================ */

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-dark, #333);
}

.checkbox-label input[type="checkbox"] {
  margin: 0;
}

/* ============================================================
   Password Reset Link
   ============================================================ */

.reset-link {
  text-align: center;
  margin-top: 12px;
  font-size: 13px;
}

.reset-link a {
  color: var(--text-light, #888);
}

.msg.success {
  display: block;
  color: #2a7d2a;
  background: #e8f5e8;
  border: 1px solid #b8dab8;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 13px;
}

/* ============================================================
   Log Viewer
   ============================================================ */

.log-filters {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.log-count {
  font-size: 13px;
  color: var(--text-light, #888);
  margin-bottom: 8px;
}

.log-search {
  margin-bottom: 12px;
}

.log-search input {
  width: 100%;
  max-width: 500px;
}

.log-ts {
  font-size: 12px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.log-docid {
  font-family: monospace;
  font-size: 12px;
  color: var(--text-light, #888);
}

.log-user {
  font-size: 13px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-summary {
  font-size: 12px;
  color: var(--text-light, #666);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-detail {
  background: none;
  border: 1px solid var(--border, #ccc);
  border-radius: 4px;
  cursor: pointer;
  padding: 2px 8px;
  font-size: 14px;
  color: var(--text-light, #888);
}

.btn-detail:hover {
  background: var(--bg-accent, #e8f4e8);
}

.badge-created { background: #d4edda; color: #155724; }
.badge-changed { background: #fff3cd; color: #856404; }
.badge-deleted { background: #f8d7da; color: #721c24; }

/* ============================================================
   Mandanten-Konfigurations-Editor (Phase 2)
   ============================================================ */

.mc-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  margin-top: 10px;
}

.mc-tab {
  background: #f0f0f0;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-light);
  cursor: pointer;
  position: relative;
  transition: background 0.15s, color 0.15s;
}

.mc-tab:hover {
  background: #e8e8e8;
  color: var(--text);
}

.mc-tab-active {
  background: var(--bg-white);
  color: var(--primary-dark);
  border-bottom: 2px solid var(--bg-white);
  margin-bottom: -2px;
  font-weight: 600;
}

.mc-tab .mc-dirty-dot {
  display: none;
  color: #f9a825;
  margin-left: 6px;
  font-size: 10px;
  vertical-align: middle;
}

.mc-tab-dirty .mc-dirty-dot {
  display: inline-block;
}

.mc-tab-content {
  background: var(--bg-white);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.mc-section h3 {
  font-size: 16px;
  color: var(--primary-dark);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.mc-section h4 {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 8px;
}

.mc-info-box {
  background: #e3f2fd;
  border-left: 4px solid #1976d2;
  border-radius: 4px;
  padding: 12px 16px;
  margin: 12px 0 20px 0;
  font-size: 13px;
  color: #0d47a1;
}

.mc-info-box h4 {
  color: #0d47a1;
  margin-bottom: 8px;
}

.mc-info-box p {
  margin-bottom: 8px;
}

.mc-info-box p:last-child {
  margin-bottom: 0;
}

.mc-info-box ul,
.mc-info-box ol {
  margin: 8px 0 8px 24px;
}

.mc-info-box li {
  margin-bottom: 6px;
  line-height: 1.6;
}

.mc-info-box code {
  background: rgba(0, 0, 0, 0.08);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  color: #0d47a1;
  word-break: break-all;
}

.mc-info-box a {
  color: #0d47a1;
  text-decoration: underline;
}

.mc-info-placeholder {
  background: #fff3e0;
  border-left-color: #f57c00;
  color: #e65100;
}

.mc-info-placeholder p {
  color: #e65100;
}

.mc-actions {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.mc-logo-area {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: #fafafa;
}

.mc-logo-preview {
  max-width: 300px;
  padding: 12px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 4px;
  display: inline-block;
}

.mc-logo-preview img {
  max-width: 100%;
  max-height: 150px;
  display: block;
}

.mc-logo-empty {
  color: var(--text-light);
  font-style: italic;
  padding: 20px 0;
  text-align: center;
  background: white;
  border: 1px dashed var(--border);
  border-radius: 4px;
}

/* Form-Row: zwei Spalten nebeneinander */
.mc-section .form-row {
  display: flex;
  gap: 16px;
}

.mc-section .form-row .form-group {
  flex: 1;
}

/* Kontextmenü-Eintrag "Konfiguration" hervorheben */
#mandantCtxMenu .ctx-item:first-child {
  font-weight: 500;
  color: var(--primary-dark);
}

/* Leere Tabellenhinweise (Preiskategorien/Anmeldeformular) */
.mc-empty-hint {
  padding: 24px;
  text-align: center;
  color: var(--text-light);
  font-style: italic;
  background: #fafafa;
  border: 1px dashed var(--border);
  border-radius: 4px;
  margin-bottom: 16px;
}

/* Breites Modal (z.B. Einwilligung mit Textareas DE+FR) */
.modal.modal-wide {
  max-width: 720px;
  width: 90%;
}

/* Form-Rows in Modals: auch zwei Spalten */
.modal .form-row {
  display: flex;
  gap: 16px;
}

.modal .form-row .form-group {
  flex: 1;
}

/* btn-small für kompakte Aktionen in Tabellen */
.btn-small {
  padding: 4px 10px;
  font-size: 12px;
}
