/* ================================
   File: auftraege.css
   Overrides & layout for Aufträge page. Should be included after base.css.
   Relies on tokens in design-tokens.css and component styles in components/*.css
   ================================ */

/* Container overflow */
#orders-container {
  overflow-x: auto;
}

/* Card wrapper for orders */
.card-auftraege {
  background: var(--color-surface);
  border-radius: var(--border-radius-lg);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-sm);
  max-width: 100%;
  width: 100%;
}

/* Table styling */
#orders-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--spacing-md);
  font-size: 0.95rem;
  border-radius: var(--border-radius-lg);
  overflow: hidden;
}
#orders-table thead {
  background-color: var(--color-secondary);
  color: var(--color-surface);
}
#orders-table th,
#orders-table td {
  padding: var(--spacing-sm) var(--spacing-md);
  text-align: left;
  border-bottom: 1px solid var(--color-border-light);
}
#orders-table tbody tr:nth-child(even) {
  background-color: var(--color-background);
}
#orders-table tbody tr:hover {
  background-color: rgba(0,122,204,0.1);
  transition: background var(--transition-fast);
}
#orders-table th {
  white-space: nowrap;
}

/* Responsive table */
@media (max-width: 600px) {
  #orders-table {
    font-size: var(--font-size-sm);
  }
  #orders-table,
  #orders-table thead,
  #orders-table tbody,
  #orders-table tr,
  #orders-table td {
    display: block;
  }
  #orders-table thead {
    display: none;
  }
  #orders-table tr {
    margin-bottom: var(--spacing-md);
    border-radius: var(--border-radius);
    background: var(--color-surface);
    box-shadow: var(--shadow-sm);
    padding: var(--spacing-sm);
  }
  #orders-table td {
    display: block;
    padding: var(--spacing-xs) 0;
    border: none;
    border-bottom: 1px solid var(--color-border-light);
    font-size: var(--font-size-sm);
    word-wrap: break-word;
    white-space: normal;
    overflow-wrap: break-word;
  }

  #orders-table td::before {
    content: attr(data-label);
    display: block;
    font-weight: bold;
    margin-bottom: 2px;
  }
}

/* Filter container and filters */
.filter-container {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-xl);
  margin-bottom: var(--spacing-lg);
  justify-content: space-between;
}
.kunden-filter,
.ordner-filter {
  flex: 1 1 45%;
}

/* Filterleisten-Layout – Styling kommt jetzt von Bootstrap (.btn) */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-sm);
}

/* Buttons in der Filterbar als "Chips" nebeneinander */
.filter-bar .btn {
  flex: 0 0 auto;
}

/* Optional: auf schmalen Screens Buttons untereinander */
@media (max-width: 768px) {
  .filter-bar {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .filter-bar .btn {
    flex: 1 0 48%;
  }
}


/* Selected heading – jetzt im Card-Header links */
.selected-heading {
  margin: 0;
  font-size: var(--font-size-h2);
  color: var(--color-primary-dark);
  text-align: left;
}

.selected-subtitle {
  margin-top: 4px;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}


/* Loader animation */
@keyframes rotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
#orders-container.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: var(--font-size-lg);
  color: var(--color-primary-dark);
  min-height: 300px;
}
#orders-container.loading .loader-icon {
  display: inline-block;
  animation: rotate 1.5s linear infinite;
  font-size: var(--font-size-xl);
}

/* Modal override for backdrop blur */
.modal {
  backdrop-filter: blur(3px);
}

/* Autocomplete suggestions */
.autocomplete-suggestions {
  position: absolute;
  top: 100%; left: 0; right: 0;
  max-height: 200px;
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
  z-index: 2000;
}
.autocomplete-suggestions:empty {
  border: none;
  box-shadow: none;
}
.autocomplete-suggestions .suggestion {
  padding: var(--spacing-sm) var(--spacing-md);
  cursor: pointer;
  white-space: nowrap;
}
.autocomplete-suggestions .suggestion:hover,
.autocomplete-suggestions .suggestion.selected {
  background: var(--color-background);
}

/* Alerts */
.success {
  background: #e0f7e9;
  color: #2e7d32;
  padding: var(--spacing-sm);
  border-radius: var(--border-radius);
  font-size: var(--font-size-sm);
}
.error {
  background: #ffe5e5;
  color: #d8000c;
  padding: var(--spacing-sm);
  border-radius: var(--border-radius);
  font-size: var(--font-size-sm);
}

/* Readonly composite form field */
#auftragComposite[readonly] {
  background-color: var(--color-surface);
  color: var(--color-border-muted);
  border-color: var(--color-border);
  cursor: not-allowed;
  opacity: 1;
}


/* Explorer-Icon nur am Desktop zeigen */
@media (min-width: 992px) {
  .btn-open {
    cursor: pointer;
    border: none;
    background: transparent;
    font-size: 1.25rem; /* Icon etwas größer */
  }
}
@media (max-width: 991px) {
  .btn-open { display: none; }
}

a.btn-hero { display:inline-flex; align-items:center; gap:6px; padding:4px; }
a.btn-hero img { width:22px; height:22px; object-fit:contain; }
.btn-hero.disabled { opacity:.4; cursor:not-allowed; }


/* Selects optisch wie die anderen Eingabefelder */
#feld-measure,
#feld-employees {
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  background: var(--color-surface);
  font: inherit;
}


/* ─── Chips-Multiselect Styles (angepasst) ───────────────────── */
.ms{position:relative;}
.ms-control{display:flex;flex-wrap:wrap;gap:6px;align-items:center;min-height:44px;
  background:var(--color-surface);border:1px solid var(--color-border);border-radius:var(--border-radius);
  padding:8px 10px;cursor:text;box-shadow:0 1px 0 rgba(0,0,0,.02);}
.ms-control:focus-within{outline:3px solid var(--color-primary-100,#93c5fd);outline-offset:1px;border-color:var(--color-primary);}
.ms-input{flex:1 1 140px;min-width:120px;border:0;outline:0;font:inherit;padding:6px 4px;background:transparent;}
.caret{border:0;background:transparent;cursor:pointer;padding:6px;margin-left:auto;color:#475569;}
.ms-list{position:absolute;z-index:100;top:100%;left:0;right:0;margin-top:6px;background:var(--color-surface);
  border:1px solid var(--color-border);border-radius:12px;box-shadow:var(--shadow-md);max-height:260px;overflow:auto;display:none;}
.ms.open .ms-list{display:block;}
.item{display:flex;align-items:center;gap:10px;padding:10px 12px;cursor:pointer;}
.item[aria-selected="true"]{background:#f1f5f9;}
.item.active{outline:2px solid var(--color-primary-100,#93c5fd);outline-offset:-2px;}
.item .avatar{width:28px;height:28px;border-radius:50%;display:grid;place-items:center;font-weight:700;background:#e2e8f0;color:#334155;overflow:hidden;}
.item img{width:100%;height:100%;object-fit:cover;border-radius:50%;}
.item .meta{display:flex;flex-direction:column;}
.item .name{font-size:14px;}
.item .note{font-size:12px;color:var(--color-text-muted,#6b7280);}
.empty{padding:12px;color:var(--color-text-muted,#6b7280);font-size:14px;}
.chip{display:inline-flex;align-items:center;gap:6px;padding:5px 8px;border-radius:999px;background:#eef2ff;border:1px solid #c7d2fe;font-size:13px;line-height:1;}
.chip .avatar{width:18px;height:18px;border-radius:50%;display:grid;place-items:center;font-size:11px;background:#e2e8f0;color:#334155;font-weight:600;overflow:hidden;}
.chip button{border:0;background:transparent;cursor:pointer;padding:0;line-height:1;font-size:16px;color:#64748b;}
.chip button:hover{color:#ef4444;}


.year-badge { font-weight:600; padding:2px 8px; border-radius:999px; background:#eef; }

/* Kompakte Segmented-Control für Ordner-Typ */
.label-tight { margin-bottom: 4px; display:inline-block; }

.segmented {
  display: inline-flex;
  gap: 0;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--color-surface);
}

.segmented input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented label {
  padding: 6px 14px;
  font: inherit;
  cursor: pointer;
  user-select: none;
  border-right: 1px solid var(--color-border);
  line-height: 1.3;
}

.segmented label:last-of-type { border-right: 0; }

/* aktiver Zustand via :checked + label */
.segmented input[type="radio"]:checked + label {
  background: var(--color-primary);
  color: var(--color-surface);
}

/* Fokus sichtbar machen (A11y) */
.segmented input[type="radio"]:focus + label {
  outline: 3px solid var(--color-primary-100, #93c5fd);
  outline-offset: -3px;
}

/* Hover */
.segmented label:hover { background: var(--color-background); }
.segmented input[type="radio"]:checked + label:hover { background: var(--color-primary-dark); }


/* Jahres-/S-Ordner-Filter */
.year-filter {
  margin: var(--spacing-md) 0 var(--spacing-lg);
}

/* nutzt vorhandene .filter-bar-Styles; nur Feinheiten: */
#yearFilterBar button {
  min-width: 64px;
}
#yearFilterBar button.sordner {
  min-width: 96px;
}

.hidden { display: none !important; }

/* Segmented: neutrales Gehäuse, aktives Segment pill-blau */
.segmented{
  display:inline-flex;
  align-items:stretch;              /* gleiche Höhe für alle Kinder */
  gap:0;
  padding:2px;                      /* innenrunde Kante */
  border:1px solid var(--color-border);
  border-radius:9999px;
  background: var(--color-surface); /* NICHT blau */
}

.segmented input[type="radio"]{
  position:absolute; opacity:0; pointer-events:none;
}

.segmented label{
  display:inline-flex;
  align-items:center;               /* vertikal mittig */
  justify-content:center;
  padding:8px 16px;                 /* Höhe hier steuern */
  border-radius:9999px;             /* macht die „Pill“-Form */
  line-height:1;
  color:var(--color-text);
  background:transparent;           /* inaktiv: neutral */
  user-select:none; cursor:pointer;
  border-right:1px solid var(--color-border); /* dünner Trenner */
}

.segmented label:last-of-type{ border-right:0; }

/* aktiv: nur das gewählte Segment blau – gleiche Höhe wie Container */
.segmented input[type="radio"]:checked + label{
  background:var(--color-primary);
  color:var(--color-surface);
}

/* Fokus/Hover optional */
.segmented input[type="radio"]:focus + label{
  outline:3px solid var(--color-primary-100, #93c5fd);
  outline-offset:0;
}
.segmented label:hover{ background:rgba(0,0,0,0.03); }
.segmented input[type="radio"]:checked + label:hover{ background:var(--color-primary); }

/* 2-Spalten-Zeilen im Modal */
.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-lg);
}
@media (max-width: 800px) {
  .row-2 { grid-template-columns: 1fr; }
}

/* Year & Nummer als kleine Badges in der Titelzeile */
.year-badge,
.nummer-badge {
  display: inline-block;
  margin-left: .5rem;
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: .95rem;
  background: #eef2ff;          /* dezent */
  color: #1e3a8a;
}
.nummer-badge { background: #e0f2fe; color: #075985; }

.hidden { display: none !important; }


/* Kopfbereich: links Titel, rechts Suche + Button */
.card-header--toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-md);
}

.card-header-main {
  flex: 1 1 auto;
  min-width: 0;
}

/* Rechte Seite: vertikale Toolbar */
.card-header--toolbar .toolbar {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
}

/* Suche etwas breiter halten */
.auftraege-search {
  min-width: 260px;
}

/* Responsiv: untereinander stapeln */
@media (max-width: 768px) {
  .card-header--toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .card-header--toolbar .toolbar {
    align-items: stretch;
  }

  .auftraege-search {
    width: 100%;
  }
}


/* Filter gestrafft: weniger Abstand, kleinere Buttons */
.filter-container{
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-md);
}
.kunden-filter h3,
.ordner-filter h3,
.sordner-filter h3{
  font-size: 1.05rem;
  margin: 0 0 6px 0;
}
.filter-bar{
  gap: 6px;
}
.filter-bar button{
  padding: 6px 10px;        /* vorher größer */
  min-width: 64px;          /* vorher 80px */
  font-weight: 600;         /* etwas leichter als "bold-bold" */
  border-radius: 12px;
}

/* Tabelle enger an Filter heranrücken */
#orders-table{
  margin-top: var(--spacing-sm);
}

/* Pflichtfeld-Markierung (roter Stern) im "Neues Projekt"-Modal */
#modalNewAuftrag .field-group.is-required .eh-ac-label::after,
#modalNewAuftrag .field-group.is-required .form-label::after,
#modalNewAuftrag .mb-3.is-required > label::after {
  content: " *";
  color: #dc2626; /* rot */
}

/* Optische Hervorhebung nicht ausgefüllter Pflichtfelder */
#modalNewAuftrag .field-invalid .eh-ac,
#modalNewAuftrag .field-invalid .form-control,
#modalNewAuftrag .field-invalid textarea {
  border-color: #dc2626 !important;
  box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.35);
}

/* Fallback für Button-Rand im Autocomplete */
#modalNewAuftrag .field-invalid .eh-ac-btn {
  border-color: #dc2626 !important;
}

/* ► Sternchen an allen Pflichtfeld-Labels im "Neues Projekt"-Modal */
#modalNewAuftrag .field-group.is-required > label::after {
  content: " *";
  margin-left: 0.25rem;
  color: var(--eh-color-danger, #dc3545);
  font-weight: 600;
}

/* ► Fehlerzustand: rote Umrandung für eh-autocomplete + Textarea */
#modalNewAuftrag .field-group.field-invalid .eh-ac-btn,
#modalNewAuftrag .field-group.field-invalid .beschreibung-field {
  border-color: var(--eh-color-danger, #dc3545);
  box-shadow: 0 0 0 1px rgba(220, 53, 69, 0.35);
}

/* Optional: Platzhalter im Fehlerzustand leicht abdunkeln */
#modalNewAuftrag .field-group.field-invalid .eh-ac-btn span,
#modalNewAuftrag .field-group.field-invalid .beschreibung-field::placeholder {
  color: rgba(220, 53, 69, 0.7);
}

.orders-empty {
  border-radius: var(--border-radius-lg);
  border: 1px dashed var(--color-border);
  padding: var(--spacing-md);
  margin: var(--spacing-md) 0;
  text-align: center;
  background: var(--color-background);
}

.orders-empty-text {
  margin-bottom: var(--spacing-sm);
  font-size: 0.95rem;
  color: var(--color-text-muted);
}


/* Tags im Projekt-Details-Modal */
.eh-tags-container,
.eh-tags-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.eh-tag-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  background: rgba(25, 135, 84, 0.08);
  border: 1px solid rgba(25, 135, 84, 0.35);
  cursor: default;
}

.eh-tag-pill button {
  border: none;
  background: transparent;
  margin-left: 0.25rem;
  padding: 0;
  line-height: 1;
  cursor: pointer;
}

.eh-tag-pill--suggestion {
  cursor: pointer;
  background: rgba(108, 117, 125, 0.06);
  border-color: rgba(108, 117, 125, 0.4);
}

.eh-tag-pill--suggestion.eh-tag-pill--active {
  background: rgba(25, 135, 84, 0.1);
  border-color: rgba(25, 135, 84, 0.7);
}
