/* ICP Storage - Walther Systemtechnik Brand & Style Guide v1.0 */
:root {
  --blue-primary:   #0091d1;
  --blue-dark:      #006fa3;
  --blue-light:     #e6f5fb;
  --navy:           #495a65;
  --navy-dark:      #3c4b54;
  --charcoal:       #3a3a3a;
  --gray-medium:    #b3bfcc;
  --gray-light:     #f1f1f1;
  --gray-border:    #e4e4e4;
  --white:          #ffffff;
  --danger:         #d1001a;
  --success:        #1e8e5a;

  /* Aliase (fuer bestehende Komponenten) */
  --color-primary:  var(--blue-primary);
  --color-dark:     var(--charcoal);
  --color-gray:     var(--navy);
  --color-white:    var(--white);
  --color-light:    var(--gray-light);
  --color-border:   var(--gray-border);
  --color-success:  var(--success);
  --color-danger:   var(--danger);

  --font-main:      'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius:         4px;
  --radius-sm:      2px;
  --shadow:         0 1px 4px rgba(0,0,0,.10);
  --shadow-hover:   0 4px 12px rgba(0,0,0,.12);
  --max-width:      1180px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-main);
  background: var(--gray-light);
  color: var(--charcoal);
  font-size: 16px;
  line-height: 1.6;
}
a { color: var(--blue-primary); text-decoration: none; }
a:hover { color: var(--blue-dark); text-decoration: underline; }
h1, h2, h3 { color: var(--charcoal); margin: 0 0 .6em; font-weight: 700; }
h1 { font-size: 1.75rem; line-height: 1.2; }
h2 { font-size: 1.25rem; line-height: 1.3; }
p { margin: 0 0 1em; color: var(--charcoal); }
.muted { color: var(--navy); font-size: .875rem; }
code { background: var(--gray-light); border-radius: var(--radius-sm); padding: .1em .35em; font-size: .9em; }

/* Header */
.app-header {
  background: var(--white);
  color: var(--charcoal);
  border-bottom: 1px solid var(--gray-border);
  box-shadow: var(--shadow);
}
.app-header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  height: 64px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; white-space: nowrap; color: var(--charcoal); text-decoration: none; transition: opacity .2s ease; }
.brand:hover { color: var(--charcoal); text-decoration: none; opacity: .75; }
.brand img.brand-logo { height: 38px; width: auto; display: block; }
.brand-text { color: var(--charcoal); }
.brand-text strong { font-weight: 700; }
.main-nav { display: flex; gap: 4px; flex: 1; }
.main-nav a {
  color: var(--navy);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: .9rem;
  text-decoration: none;
}
.main-nav a:hover { background: var(--blue-light); color: var(--blue-dark); }
.main-nav a.active { background: var(--blue-light); color: var(--blue-primary); }
.user-box { display: flex; align-items: center; gap: 10px; font-size: .9rem; white-space: nowrap; color: var(--navy); }

.nav-toggle {
  display: none; background: none; border: none; cursor: pointer; padding: 8px;
  flex-direction: column; justify-content: center; gap: 5px; margin-left: auto;
}
.nav-toggle span { display: block; width: 22px; height: 2px; background: var(--charcoal); border-radius: 2px; }

.app-main { max-width: var(--max-width); margin: 0 auto; padding: 32px 24px 64px; }
.app-footer { text-align: center; color: var(--navy); font-size: .8rem; padding: 24px; }

/* Cards */
.card {
  background: var(--white);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 24px;
  transition: box-shadow .25s ease;
}
.card + .card { margin-top: 24px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 2px solid transparent; border-radius: var(--radius-sm);
  padding: .75rem 1.75rem; font-size: .875rem; font-weight: 600;
  letter-spacing: .02em;
  cursor: pointer; font-family: inherit; min-height: 42px;
  transition: all .2s ease;
}
.btn-primary { background: var(--blue-primary); border-color: var(--blue-primary); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); text-decoration: none; }
.btn-secondary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-secondary:hover { background: var(--navy-dark); border-color: var(--navy-dark); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--navy); border: 2px solid var(--gray-border); }
.btn-ghost:hover { background: var(--gray-light); text-decoration: none; }
.btn-outline { background: transparent; color: var(--blue-primary); border: 2px solid var(--blue-primary); }
.btn-outline:hover { background: var(--blue-primary); color: #fff; text-decoration: none; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #a8000f; border-color: #a8000f; text-decoration: none; }
.btn-sm { padding: .5rem 1.25rem; min-height: 32px; font-size: .8rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Forms */
label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .825rem; color: var(--charcoal); }
input[type=text], input[type=password], input[type=email], input[type=number],
input[type=date], input[type=file], select, textarea {
  width: 100%; padding: .65rem .9rem; border: 1px solid var(--gray-medium);
  border-radius: var(--radius-sm); font-family: inherit; font-size: .9rem;
  background: #fff; color: var(--charcoal);
}
input::placeholder, textarea::placeholder { color: var(--gray-medium); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--blue-primary);
  box-shadow: 0 0 0 3px rgba(0,145,209,.15);
}
.field { margin-bottom: 18px; }
.field-hint { color: var(--navy); font-size: .78rem; margin-top: 6px; }
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row .field { flex: 1; min-width: 200px; }

/* Login page */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
  position: relative;
  background-image:
    linear-gradient(160deg, rgba(58,58,58,.85) 0%, rgba(73,90,101,.85) 100%),
    url('img/login-bg.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.login-card {
  background: #fff; border-radius: var(--radius); box-shadow: 0 20px 60px rgba(0,0,0,.35);
  padding: 40px 36px; width: 100%; max-width: 380px;
  position: relative; z-index: 1;
}
.login-card .brand-row { display: flex; flex-direction: column; align-items: center; margin-bottom: 24px; }
.login-card .brand-row img.brand-logo { height: 56px; width: auto; margin-bottom: 10px; }
.login-card h1 { text-align: center; font-size: 1.2rem; margin-top: 12px; }
.alert { padding: 12px 14px; border-radius: var(--radius); font-size: .875rem; margin-bottom: 16px; }
.alert-danger { background: #FBE7EA; color: var(--danger); border: 1px solid #F3C4CC; }
.alert-success { background: #E6F5EE; color: var(--success); border: 1px solid #BEEBD4; }
.alert-info { background: var(--blue-light); color: var(--blue-dark); border: 1px solid #C7E7F5; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th, td { text-align: left; padding: .7rem 1rem; border-bottom: 1px solid var(--gray-border); vertical-align: top; }
th { color: var(--white); background: var(--navy); font-weight: 700; text-transform: uppercase; font-size: .72rem; letter-spacing: .04em; }
tbody tr:nth-child(odd) { background: var(--gray-light); }
tbody tr:hover { background: var(--blue-light); }
.table-wrap { overflow-x: auto; overflow-y: hidden; border-radius: var(--radius); border: 1px solid var(--gray-border); }
.table-wrap table { border: none; }

/* Dashboard: Dateiname-Spalte begrenzen, damit lange Dateinamen nicht die
   gesamte Tabelle in die Breite treiben und ein Scrollen erzwingen */
.col-file { max-width: 260px; word-break: break-word; overflow-wrap: anywhere; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .72rem; font-weight: 700; }
.badge-new { background: #E6F5EE; color: var(--success); }
.badge-dup { background: #FBE7EA; color: var(--danger); }
.badge-synced { background: var(--blue-light); color: var(--blue-dark); }
.badge-neutral { background: var(--gray-light); color: var(--navy); }

/* Import: Steps */
.steps { display: flex; gap: 8px; margin-bottom: 24px; }
.step {
  flex: 1; padding: 10px 14px; border-radius: var(--radius); background: #fff;
  border: 1px solid var(--gray-border); color: var(--navy); font-size: .8rem; font-weight: 600;
}
.step.active { border-color: var(--blue-primary); color: var(--blue-primary); background: var(--blue-light); }
.step.done { border-color: var(--success); color: var(--success); background: #E6F5EE; }

/* Mapping-Presets (Speichern/Laden) */
.mapping-preset-row { align-items: flex-end; }

/* Drag & Drop mapping */
.mapping-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 760px) { .mapping-wrap { grid-template-columns: 1fr; } }
.mapping-col h3 { font-size: .95rem; }
/* "Spalten aus der Datei" bleibt beim Scrollen der (oft laengeren) Feldliste sichtbar */
.mapping-col:first-child {
  position: sticky;
  top: 16px;
  align-self: start;
}
.chip-pool {
  border: 2px dashed var(--gray-border); border-radius: var(--radius);
  padding: 12px; min-height: 90px; max-height: calc(100vh - 120px); overflow-y: auto;
  display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px; background: #fff;
}
.chip {
  background: var(--navy); color: #fff; padding: 6px 12px; border-radius: 10px;
  font-size: .8rem; cursor: grab; user-select: none;
  display: flex; flex-direction: column; gap: 1px; line-height: 1.3; max-width: 220px;
}
.chip-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip-sample { font-weight: 400; font-size: .72rem; color: rgba(255,255,255,.75); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip:active { cursor: grabbing; }
.chip.placed { opacity: .35; cursor: not-allowed; }
.field-group { margin-bottom: 16px; }
.field-group-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--blue-primary); font-weight: 700; margin-bottom: 8px; }
.dropzone {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1px solid var(--gray-border); border-radius: var(--radius);
  padding: 8px 10px; margin-bottom: 6px; background: #fff; min-height: 40px;
}
.dropzone.dragover { border-color: var(--blue-primary); background: var(--blue-light); }
.dropzone .field-label { font-size: .82rem; color: var(--charcoal); flex-shrink: 0; }
.dropzone .dropped-chip { flex: 1; display: flex; justify-content: flex-end; align-items: center; }
.dropzone .dropped-chip .chip { background: var(--blue-primary); }
.dropzone .remove-chip { background: none; border: none; color: var(--navy); cursor: pointer; font-size: 1rem; line-height: 1; padding: 2px 4px; }

.duplicate-row td { background: #FCEFF1; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

/* Dashboard */
tr.batch-row:hover { background: var(--blue-light); }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; white-space: nowrap; }

/* Bestaetigungs-Popup (Modal) */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(58,58,58,.55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 1000;
}
.modal {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-hover);
  padding: 28px 32px; width: 100%; max-width: 460px;
}
.modal h2 { margin-bottom: .5em; }
.modal p { color: var(--charcoal); }

/* ========================================================================
   Responsive: Tablet & Smartphone
   ======================================================================== */

/* Tablet (<=860px): Hauptnavigation klappt zu einem Ausklapp-Menue zusammen */
@media (max-width: 860px) {
  .app-header-inner {
    flex-wrap: wrap;
    height: auto;
    min-height: 60px;
    padding: 10px 16px;
    row-gap: 0;
  }
  .brand { order: 1; }
  .nav-toggle { display: flex; order: 2; }
  .main-nav, .user-box {
    display: none;
    width: 100%;
  }
  .app-header-inner.nav-open .main-nav,
  .app-header-inner.nav-open .user-box {
    display: flex;
  }
  .main-nav {
    order: 3;
    flex-direction: column;
    gap: 2px;
    margin: 8px 0 4px;
  }
  .main-nav a { padding: 12px 14px; }
  .user-box {
    order: 4;
    justify-content: space-between;
    border-top: 1px solid var(--gray-border);
    padding: 12px 0 10px;
  }
}

/* Tablet & Smartphone: mehr Platz fuer Inhalte, kompaktere Abstaende */
@media (max-width: 760px) {
  .app-main { padding: 20px 16px 48px; }
  .card { padding: 18px; margin-bottom: 18px; }
  h1 { font-size: 1.4rem; }
  h2 { font-size: 1.1rem; }

  /* Toolbars stapeln sich, Buttons werden volle Breite -> leichter antippbar */
  .toolbar { flex-direction: column; align-items: stretch; }

  /* Import-Fortschrittsanzeige: 2x2 statt einer engen 4er-Reihe */
  .steps { flex-wrap: wrap; }
  .step { flex: 1 1 calc(50% - 4px); text-align: center; font-size: .74rem; padding: 8px 6px; }

  .modal { padding: 22px 20px; }
}

/* Smartphone (<=700px): Tabellen werden zu Karten mit Feld-Label je Zeile,
   damit nicht seitlich gescrollt werden muss */
@media (max-width: 700px) {
  .table-wrap table thead { display: none; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td {
    display: block; width: 100%;
  }
  .table-wrap tr {
    border: 1px solid var(--gray-border);
    border-radius: var(--radius);
    margin-bottom: 12px;
    overflow: hidden;
  }
  .table-wrap tr:last-child { margin-bottom: 0; }
  .table-wrap tbody tr:nth-child(odd) { background: var(--white); }
  .table-wrap td {
    padding: 10px 12px; border-bottom: 1px solid var(--gray-border);
    text-align: left; word-break: break-word; overflow-wrap: anywhere;
  }
  .table-wrap td:last-child { border-bottom: none; }
  .table-wrap td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-weight: 700; color: var(--navy); text-transform: uppercase;
    font-size: .68rem; letter-spacing: .03em; margin-bottom: 3px;
  }
}

/* Kleine Smartphones */
@media (max-width: 420px) {
  .login-card { padding: 28px 22px; }
  .btn { padding: .7rem 1.1rem; }
  .step { flex: 1 1 100%; }
}
