/**
 * Buchhaltung Modul - CSS
 * Styles für Drag & Drop und Beleg-Upload
 */

/* Drag & Drop Zone */
.drag-drop-zone {
  position: relative;
  flex: 1;
  min-width: 200px;
  min-height: 140px;
  border: 2px dashed #d1d5db;
  border-radius: 8px;
  background-color: #f9fafb;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.dark .drag-drop-zone {
  background-color: #1f2937;
  border-color: #4b5563;
}

.drag-drop-zone:hover {
  border-color: #3b82f6;
  background-color: #eff6ff;
}

.dark .drag-drop-zone:hover {
  border-color: #60a5fa;
  background-color: #1e3a8a;
}

.drag-drop-zone.drag-over {
  border-color: #3b82f6;
  background-color: #dbeafe;
  transform: scale(1.02);
}

.dark .drag-drop-zone.drag-over {
  border-color: #60a5fa;
  background-color: #1e40af;
}

.drag-drop-content {
  text-align: center;
  padding: 1.5rem;
}

.drag-drop-content svg {
  margin: 0 auto 0.75rem;
}

.drag-drop-processing {
  text-align: center;
  padding: 2rem;
}

/* Loader Animation */
.loader {
  border: 3px solid #f3f4f6;
  border-top: 3px solid #3b82f6;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
}

.dark .loader {
  border: 3px solid #4b5563;
  border-top: 3px solid #60a5fa;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Booking Line Items */
.booking-line-item {
  transition: all 0.2s ease;
}

.booking-line-item:hover {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Account Search Input - Apple OS X Style */
.booking-line-item input[type="text"],
.booking-line-item select {
  border: 1px solid #d1d5db;
  transition: all 0.15s ease;
}

.booking-line-item input[type="text"]:focus,
.booking-line-item select:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.dark .booking-line-item input[type="text"],
.dark .booking-line-item select {
  border: 1px solid #4b5563;
}

.dark .booking-line-item input[type="text"]:focus,
.dark .booking-line-item select:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.1);
}

/* Select-Dropdown styling */
.booking-line-item select {
  cursor: pointer;
  appearance: none;
  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-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: 2.5rem;
}

.dark .booking-line-item select {
  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='%9ca3af' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
}

/* Actions Dropdown */
.actions-dropdown {
  animation: slideDown 0.15s ease-out;
}

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

/* Booking Details Section */
.booking-details-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #e5e7eb;
}

.dark .booking-details-section {
  border-top-color: #374151;
}

.booking-details-section table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}

.booking-details-section th,
.booking-details-section td {
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.booking-details-section th {
  font-weight: 500;
  background-color: #f9fafb;
}

.dark .booking-details-section th {
  background-color: #374151;
}

.booking-details-section tbody tr:nth-child(even) {
  background-color: #f9fafb;
}

.dark .booking-details-section tbody tr:nth-child(even) {
  background-color: #1f2937;
}

/* =============================================
   Neue Buchung Modal - BuchhaltungsButler Style
   ============================================= */

.new-booking-modal {
  min-width: 520px;
}

/* Zeilen-Layout */
.nb-row {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

/* Feld-Container */
.nb-field {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.nb-field-date {
  flex: 0 0 140px;
}

.nb-field-desc {
  flex: 1;
}

.nb-field-amount {
  flex: 0 0 130px;
}

.nb-field-account {
  flex: 1;
  position: relative;
}

/* Clear-Button (×) innerhalb der Konto-Felder */
.nb-input-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  color: #9ca3af;
  font-size: 1.1rem;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  z-index: 2;
}
.nb-field-account:hover .nb-input-clear,
.nb-field-account:focus-within .nb-input-clear {
  opacity: 1;
}
.nb-input-clear:hover {
  color: #ef4444;
  background: #fee2e2;
}

.nb-field-kst {
  flex: 1;
}

.nb-field-bu {
  flex: 1;
}

/* Label */
.nb-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  margin-bottom: 6px;
}

.dark .nb-label {
  color: #9ca3af;
}

/* Input-Felder */
.nb-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.875rem;
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  color: #111827;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  outline: none;
  box-sizing: border-box;
  height: 42px;
}

.dark .nb-input {
  background: #1f2937;
  border-color: #4b5563;
  color: #f3f4f6;
}

.nb-input:focus {
  border-color: #06b6d4;
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.1);
}

.dark .nb-input:focus {
  border-color: #22d3ee;
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.1);
}

.nb-input::placeholder {
  color: #9ca3af;
}

.dark .nb-input::placeholder {
  color: #6b7280;
}

/* Konto-Inputs - leicht breiter, Platz fuer Clear-Button */
.nb-account-input {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.8125rem;
  padding-right: 28px;
}

/* Custom Account Autocomplete Dropdown */
.nb-account-dropdown {
  scrollbar-width: thin;
  scrollbar-color: #d1d5db transparent;
}
.nb-account-dropdown::-webkit-scrollbar { width: 6px; }
.nb-account-dropdown::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
.nb-ac-item:last-child { border-bottom: none !important; }
.nb-ac-item:hover { background: #eff6ff !important; }
@media (prefers-color-scheme: dark) {
  .nb-account-dropdown {
    background: #1f2937 !important;
    border-color: #374151 !important;
  }
  .nb-ac-item { border-color: #374151 !important; }
  .nb-ac-item:hover { background: #1e3a5f !important; }
  .nb-ac-item span:first-child { color: #60a5fa !important; }
  .nb-ac-item span:last-child { color: #e5e7eb !important; }
}

/* S/H Badges */
.nb-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 0.6875rem;
  font-weight: 700;
  color: #fff;
}

.nb-badge-s {
  background: #06b6d4;
}

.nb-badge-h {
  background: #f59e0b;
}

/* AI Vorschlag Bereich */
.nb-ai-bar {
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid #f3f4f6;
}

.dark .nb-ai-bar {
  border-top-color: #374151;
}

.nb-ai-bar-inner {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nb-ai-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #06b6d4;
  background: transparent;
  border: 1.5px solid #06b6d4;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nb-ai-btn:hover {
  background: rgba(6, 182, 212, 0.08);
}

.dark .nb-ai-btn {
  color: #22d3ee;
  border-color: #22d3ee;
}

.dark .nb-ai-btn:hover {
  background: rgba(34, 211, 238, 0.1);
}

/* AI Status */
.nb-ai-status {
  font-size: 0.75rem;
  color: #9ca3af;
}

.nb-ai-status.nb-ai-loading {
  color: #06b6d4;
}

.nb-ai-status.nb-ai-high {
  color: #10b981;
  font-weight: 500;
}

.nb-ai-status.nb-ai-low {
  color: #f59e0b;
}

.nb-ai-status.nb-ai-none {
  color: #9ca3af;
  font-style: italic;
}

/* AI Auto-Fill Animation */
.nb-ai-filled {
  animation: nbAiFill 0.6s ease;
}

@keyframes nbAiFill {
  0% {
    border-color: #06b6d4;
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.2);
    background-color: rgba(6, 182, 212, 0.05);
  }
  100% {
    border-color: #e5e7eb;
    box-shadow: none;
    background-color: #fff;
  }
}

.dark .nb-ai-filled {
  animation: nbAiFillDark 0.6s ease;
}

@keyframes nbAiFillDark {
  0% {
    border-color: #22d3ee;
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.2);
    background-color: rgba(34, 211, 238, 0.05);
  }
  100% {
    border-color: #4b5563;
    box-shadow: none;
    background-color: #1f2937;
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  .drag-drop-zone {
    min-height: 100px;
  }
  
  .drag-drop-content {
    padding: 1rem;
  }
  
  .drag-drop-content svg {
    width: 32px;
    height: 32px;
  }
  
  /* Stack booking fields vertically on mobile */
  .booking-line-item .flex {
    flex-direction: column;
  }
  
  .booking-line-item .w-32,
  .booking-line-item .w-24 {
    width: 100%;
  }

  /* Neue Buchung Modal responsive */
  .new-booking-modal {
    min-width: unset;
  }

  .nb-row {
    flex-direction: column;
    gap: 8px;
  }

  .nb-field-date,
  .nb-field-amount {
    flex: 1;
  }
}

/* ==============================================
   Beleg-Modal (doc-modal) -- gleicher Stil wie Buchungsmodal
   ============================================== */
.doc-modal {
  min-width: 560px;
}

.doc-section {
  margin-bottom: 20px;
}

.doc-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #e5e7eb;
}

.doc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.doc-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.doc-field {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.doc-field-full {
  grid-column: span 2;
}

.doc-field label {
  font-size: 0.75rem;
  font-weight: 500;
  color: #6b7280;
  margin-bottom: 4px;
}

.doc-field input,
.doc-field select,
.doc-field textarea {
  padding: 8px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 0.875rem;
  color: #111827;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.doc-field input:focus,
.doc-field select:focus,
.doc-field textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.doc-field input[readonly] {
  background: #f9fafb;
  color: #6b7280;
}

.doc-field input.doc-bold {
  font-weight: 600;
}

.doc-confidence {
  font-size: 0.7rem;
  margin-left: 6px;
  font-weight: 400;
}
.doc-confidence-high { color: #10b981; }
.doc-confidence-low { color: #ef4444; }

/* Legacy – kept for compatibility */
.doc-partner-row { display: flex; gap: 8px; align-items: stretch; }
.doc-partner-row input { flex: 1; }

.doc-partner-btn {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
  transition: all 0.15s;
  height: 42px;
}
.doc-partner-btn:hover { background: #f3f4f6; border-color: #9ca3af; }
.doc-partner-btn-primary { background: #3b82f6; color: #fff; border-color: #3b82f6; }
.doc-partner-btn-primary:hover { background: #2563eb; }

/* === Partner-Widget (inline Suche) === */

/* Zugewiesener Partner – grüne Badge */
.doc-partner-assigned {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: #f0fdf4;
  border: 1.5px solid #86efac;
  border-radius: 8px;
  font-size: 0.875rem;
  color: #166534;
}
.doc-partner-check {
  font-size: 0.9rem;
  color: #16a34a;
  flex-shrink: 0;
}
.doc-partner-name {
  flex: 1;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-partner-clear {
  background: none;
  border: none;
  cursor: pointer;
  color: #6b7280;
  font-size: 1rem;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
}
.doc-partner-clear:hover { color: #dc2626; }

/* Dropdown unter dem Such-Input */
.doc-partner-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 60px; /* Abstand vom "+ Neu"-Button */
  z-index: 200;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.10);
  max-height: 240px;
  overflow-y: auto;
}
.dark .doc-partner-dropdown {
  background: #1f2937;
  border-color: #374151;
}
.doc-partner-dropdown.hidden { display: none; }
.doc-partner-dd-item {
  display: flex;
  flex-direction: column;
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f3f4f6;
  transition: background 0.1s;
}
.doc-partner-dd-item:last-child { border-bottom: none; }
.doc-partner-dd-item:hover { background: #eff6ff; }
.dark .doc-partner-dd-item:hover { background: #1e3a5f; }
.doc-partner-dd-item strong { font-size: 0.875rem; color: #111827; }
.dark .doc-partner-dd-item strong { color: #f3f4f6; }
.doc-partner-dd-item span { font-size: 0.75rem; color: #6b7280; margin-top: 1px; }
.doc-partner-dd-hint {
  padding: 10px 12px;
  font-size: 0.8rem;
  color: #9ca3af;
  text-align: center;
}

@media (max-width: 640px) {
  .doc-modal {
    min-width: unset;
  }
  .doc-grid,
  .doc-grid-3 {
    grid-template-columns: 1fr;
  }
  .doc-field-full {
    grid-column: span 1;
  }
}

/* === Festgeschriebene Buchungen (dezent grün) === */
tr.booking-locked {
  background: rgba(236, 253, 245, 0.4);
}
tr.booking-locked:hover {
  background: rgba(236, 253, 245, 0.6) !important;
}
@media (prefers-color-scheme: dark) {
  tr.booking-locked {
    background: rgba(6, 78, 59, 0.08);
  }
  tr.booking-locked:hover {
    background: rgba(6, 78, 59, 0.15) !important;
  }
}

