/* =============================================================================
   DIWO Vergleich - Global CSS
   =============================================================================
   
   Gemeinsame Stile die von allen Seiten verwendet werden:
   - CSS Custom Properties (Variablen)
   - Reset & Base Styles
   - Layout Components
   - Form Elements
   - Button Styles
   - Table Styles
   - Section Components (Collapsible Sections)
   ============================================================================= */

/* =============================================================================
   CSS CUSTOM PROPERTIES (VARIABLEN)
   ============================================================================= */
:root {
  /* Standard Farben mit verbessertem Kontrast */
  --rot-hell: #ffe6e6;
  --gelb-hell: #fff8db;
  --gruen-hell: #e8f5e8;
  --rot: #b30000;
  --gelb: #9d5502;
  --gruen: #004d26;
  --weiss: #ffffff;
  --schwarz: #000000;
  --grau-hell: #f7f9fa;
  --grau-stark: #d7d8d9;
  --diwo-blau: #145c9e;
  --diwo-blau-hell: #cfe8fc;
  
  /* Focus Ring Farbe für bessere Sichtbarkeit */
  --focus-color: #0066cc;
  --focus-outline: 3px solid var(--focus-color);
}

/* Alternative Farben mit besserem Kontrast */
:root[data-color-scheme="alt-a"] {
  --rot-hell: #ffe6f5;
  --gelb-hell: #fff2cc;
  --gruen-hell: #e6f7ff;
  --rot: #cc0044;   
  --gelb: #a3590f;  
  --gruen: #0069a1; 
}

/* Alternative Pastell (ohne Ampel-Assoziation) */
:root[data-color-scheme="alt-pastell"] {
  --rot-hell:#ffeef2  ;  
  --gelb-hell:#f3e8ff; 
  --gruen-hell:  #e8f0ff;

  --rot: #af314e;      
  --gelb: #7045b4;     
  --gruen: #00499c;     
}

/* =============================================================================
   RESET & BASE STYLES
   ============================================================================= */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 16px;
  background: var(--grau-hell);
  color: var(--schwarz);
  font: 14px/1.5 system-ui, sans-serif;
}

h1, h2, h3 {
  margin: 0.2rem 0 0.6rem;
  line-height: 1.3;
}

/* Focus-Stile für bessere Keyboard-Navigation */
*:focus {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

button:focus,
select:focus,
input:focus,
.person-row:focus,
.section-header:focus {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

tr:focus {
  outline: var(--focus-outline);
  outline-offset: 1px;
  position: relative;
  z-index: 1;
}

/* =============================================================================
   LAYOUT COMPONENTS
   ============================================================================= */
.row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.grid-2 .full {
  grid-column: 1/-1;
}

.error-box {
  background: var(--rot-hell);
  border-left: 4px solid var(--rot);
  padding: 0.6rem;
  margin: 0.6rem 0;
  border-radius: 4px;
}

/* =============================================================================
   FORM ELEMENTS
   ============================================================================= */
textarea,
input,
select {
  width: 100%;
  padding: 0.5rem;
  background: var(--weiss);
  color: var(--schwarz);
  border: 2px solid var(--grau-stark);
  border-radius: 4px;
  font-size: 14px;
}

textarea:hover,
input:hover,
select:hover {
  border-color: var(--diwo-blau);
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-group label {
  font-size: 13px;
  font-weight: bold;
  white-space: nowrap;
}

/* =============================================================================
   BUTTON STYLES
   ============================================================================= */
button {
  padding: 0.5rem 0.9rem;
  border: 2px solid var(--grau-stark);
  background: var(--weiss);
  cursor: pointer;
  font-size: 14px;
  min-height: 44px; 
  transition: all 0.2s ease;
}

button:hover {
  background: var(--grau-hell);
  border-color: var(--diwo-blau);
}

button:active {
  transform: translateY(1px);
}

/* =============================================================================
   TABLE STYLES
   ============================================================================= */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--weiss);
  border: 1px solid var(--grau-stark);
  margin: 0.6rem 0 1rem;
  border-spacing: 0;
}

th, td {
  border: 1px solid var(--grau-stark);
  padding: 0.5rem;
  vertical-align: top;
  text-align: left; 
}

th {
  background: var(--grau-stark);
  position: sticky;
  top: 0;
  font-weight: bold;
  color: var(--schwarz); 
}

/* Symbol-Spalte */
.sym {
  width: 2.5rem;
  min-width: 2.5rem;
  max-width: 2.5rem;
  text-align: center;
  font-weight: 700;
  font-size: 16px; 
}

.sym.plus {
  color: var(--gruen);
}

.sym.minus {
  color: var(--rot);
}

.sym.warn {
  color: var(--gelb);
}

/* FontAwesome Icons in Symbol-Spalte */
.sym i.fas {
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-style: normal;
  font-variant: normal;
  text-rendering: auto;
  line-height: 1;
}

.sym i.fa-plus,
.sym i.fa-minus,
.sym i.fa-exclamation {
  font-size: 16px;
  display: inline-block;
}

/* Diff-Highlighting für Tabellenzeilen */
.diff-row-added {
  background: var(--gruen-hell);
}

.diff-row-removed {
  background: var(--rot-hell);
}

/* =============================================================================
   NEUE ICON-BASIERTE DIFF-DARSTELLUNG
   ============================================================================= */

/* Container für den neuen Icon+Text Layout */
.diff-content {
  display: flex;
  align-items: flex-start;
  min-height: 2.4em;
  gap: 2px;
}

.diff-icon {
  flex-shrink: 0;
  width: 18px; /* Größeres Icon */
  height: 18px; /* Größeres Icon */
  font-size: 16px; /* Größere Schrift für das Icon */
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.1em; /* Kleinerer Abstand oben */
  position: relative;
}

.diff-text {
  flex: 1;
  line-height: 1.3;
  min-width: 0; /* Verhindert Overflow-Probleme */
}

.diff-current-value {
  display: block;
  font-weight: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.diff-status-text {
  display: block;
  font-size: 0.85em;
  margin-top: 0.3rem;
  opacity: 0.9;
  font-style: italic;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Icon-spezifische Farben mit besserer Sichtbarkeit */
.diff-icon.changed {
  color: var(--gelb);
}

.diff-icon.added {
  color: var(--gruen);
}

.diff-icon.deleted {
  color: var(--rot);
}

/* FontAwesome Icons in Diff-Icons */
.diff-icon i.fas {
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-style: normal;
  font-variant: normal;
  text-rendering: auto;
  line-height: 1;
}

/* Hintergrundfarben für die Zellen */
.cell-changed,
td:has(.cell-changed) {
  background: var(--gelb-hell);
}

.cell-added,
td:has(.cell-added) {
  background: var(--gruen-hell);
}

.cell-deleted,
td:has(.cell-deleted) {
  background: var(--rot-hell);
}

/* =============================================================================
   KOPIER-BUTTONS FÜR ALTE WERTE
   ============================================================================= */
.copy-btn {
  display: inline;
  margin-left: 0.25rem;
  padding: 0;
  font-size: 10px;
  line-height: 1;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--schwarz);
  transition: all 0.15s ease;
  vertical-align: baseline;
  opacity: 0.6;
  height: auto;
  width: auto;
  min-height: unset !important;
}

.copy-btn i {
  font-size: 10px;
  line-height: 1;
  vertical-align: baseline;
}

.copy-btn:hover {
  opacity: 1;
  transform: scale(1.1);
  color: var(--schwarz);
}

.copy-btn:focus {
  outline: 1px solid var(--focus-color);
  outline-offset: 1px;
  opacity: 1;
}

.copy-btn:active {
  transform: scale(0.95);
}

/* Feedback-Stile für Kopier-Buttons */
.copy-btn.copy-success {
  color: var(--gruen);
  opacity: 1;
}

.copy-btn.copy-error {
  color: var(--rot);
  opacity: 1;
}

/* Kopier-Buttons im neuen Diff-Layout */
.diff-status-text .copy-btn {
  font-style: normal;
}

/* =============================================================================
   SECTION COMPONENTS (COLLAPSIBLE SECTIONS)
   ============================================================================= */
.section-container {
  margin: 0.6rem 0 1rem;
}

.section-header {
  background: var(--grau-stark);
  padding: 12px 16px;
  border: 2px solid var(--grau-stark);
  border-radius: 4px 4px 0 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  transition: all 0.2s ease;
  min-height: 44px;
}

.section-header:hover {
  background: #c5c6c7;
  border-color: var(--diwo-blau);
}

.section-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: bold;
}

.toggle-icon {
  font-size: 14px;
  transition: transform 0.2s ease;
  font-weight: bold;
}

.toggle-icon.collapsed {
  transform: rotate(-90deg);
}

.section-content {
  border: 2px solid var(--grau-stark);
  border-top: none;
  border-radius: 0 0 4px 4px;
  transition: max-height 0.3s ease;
  overflow: visible;
  padding: 4px;
}

.section-content.collapsed {
  display: none;
}

.section-content table {
  margin: 0;
  border: none;
}
