/* ============================================================
   Avison Studios Dashboard — Der Bereich „Kunden": Tabs, Widget-Raster, Notizen, Zähler
   Teil 3 von 6. Die Reihenfolge der <link>-Tags in index.html
   muss so bleiben, wie sie ist: in CSS gewinnt die spätere Regel.

   Ruhiges Kartensystem: keine Rahmen, weiche Schatten, Bedeutung
   durch Tonflächen. Die Kundenfarbe kommt als --client-color per
   Inline-Style an und wird als Fläche eingesetzt, nicht als Rand.
   Die Widgets liegen in der Kunden-Karte (var(--surface)), darum
   tragen sie var(--surface-2); Chips und Kacheln darin weichen auf
   var(--surface) bzw. var(--tone-almond) aus, damit sie sichtbar bleiben.
   ============================================================ */

/* ============ Kunden ============ */
.client-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.client-tab {
    font-family: var(--font-display);
    font-weight: 600;
    background: var(--surface-2);
    border: none;
    color: var(--ink);
    border-radius: var(--r-pill);
    padding: 8px 18px;
    cursor: pointer;
    font-size: 14px;
    box-shadow: none;
    transition: background 0.15s, color 0.15s, transform 0.1s;
    display: inline-flex;
    align-items: center;
    gap: 9px;
}
.client-tab:hover { background: var(--tone-almond); }
.tab-logo {
    width: 21px;
    height: 21px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--white);
    outline: 1px solid var(--line-strong);
}
/* Mit Logo zeigt der Tab nur noch das Logo – größer und sofort erkennbar */
.client-tab.logo-only { padding: 6px 12px; }
.client-tab.logo-only .tab-logo { width: 30px; height: 30px; }
.client-tab.logo-only.active .tab-logo { outline-color: rgba(255, 255, 255, 0.6); }
.client-tab:active { transform: translateY(1px); }
/* Reihenfolge ziehen: der gezogene Tab wird blass, das Ziel bekommt links
   eine orangene Kante – dieselbe Sprache wie im Widget-Raster. */
.client-tab.dragging { opacity: 0.4; }
.client-tab.drop-before { box-shadow: -3px 0 0 var(--orange); }
.cli-order { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cli-order-pos {
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0;
    color: var(--ink-2);
}
/* Aktiver Tab: Kundenfarbe als Fläche, weißer Text (ohne Kundenfarbe Charcoal) */
.client-tab.active {
    background: var(--client-color, var(--charcoal));
    color: #fff;
}
.client-tab.active:hover { background: var(--client-color, var(--charcoal)); filter: brightness(1.06); }

/* Bento im Kundenbereich: Kopf + Stats oben, darunter 3 gleiche Boxen */
.panel-bento {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
}

/* ---- Kunden-Kopf (Logo + Name + Anpassen) ---- */
.panel-head {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 2px;
}
.panel-ident { display: flex; align-items: center; gap: 14px; min-width: 0; }
.panel-logo {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    object-fit: contain;
    background: var(--surface);
    border: 1px solid var(--line);
    padding: 4px;
    flex-shrink: 0;
}
.panel-name {
    margin: 0;
    font-family: var(--font-title);
    font-size: 29px;
    font-weight: 400;
    letter-spacing: 0;
    line-height: 1.05;
    color: var(--ink);
    overflow-wrap: anywhere;
}
.posting-days { font-family: var(--font-display); font-size: 12px; font-weight: 500; letter-spacing: 0; color: var(--ink-2); }
.panel-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
/* Webseite und zweiter Link stehen immer an derselben Stelle: Kundenfarbe
   als Tonfläche mit Punkt in Vollfarbe, Text in Tinte. */
.panel-actions .client-link {
    background: color-mix(in srgb, var(--client-color, var(--charcoal)) 18%, var(--surface));
    color: var(--ink);
}
.panel-actions .client-link::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--client-color, var(--charcoal));
    flex-shrink: 0;
}
.panel-actions .client-link:hover { background: color-mix(in srgb, var(--client-color, var(--charcoal)) 30%, var(--surface)); }

/* ============ Widget-System (Apple-Style: S/M/L, Drag & Drop, Ausblenden) ============ */
/* 4-Spalten-Raster: S = 1/4, M = 1/2, L = volle Breite + doppelte Höhe.
   Die Breiten sind Vielfache voneinander, dadurch geht jede Kombination auf.
   grid-auto-flow: dense zieht kleine Widgets in verbleibende Lücken. */
.widget-grid {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 272px;
    grid-auto-flow: row dense;
    gap: 18px;
}
.widget {
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--surface-2);
    border: none;
    border-radius: 14px;
    box-shadow: none;
    padding: 14px 16px 16px;
    overflow: hidden;
}
.widget.size-s { grid-column: span 1; grid-row: span 1; }
.widget.size-m { grid-column: span 2; grid-row: span 1; }
.widget.size-l { grid-column: span 4; grid-row: span 2; }
.widget-body { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding-right: 2px; }
.widget-body::-webkit-scrollbar { width: 7px; }
.widget-body::-webkit-scrollbar-thumb { background: rgba(var(--ink-rgb), 0.22); border-radius: 4px; }
@media (max-width: 1020px) {
    .widget-grid { grid-template-columns: repeat(2, 1fr); }
    .widget.size-s { grid-column: span 1; }
    .widget.size-m, .widget.size-l { grid-column: span 2; }
}
@media (max-width: 620px) {
    .widget-grid { grid-template-columns: 1fr; grid-auto-rows: auto; }
    .widget.size-s, .widget.size-m, .widget.size-l { grid-column: span 1; grid-row: span 1; }
    .widget-body { overflow-y: visible; max-height: 420px; }
}
.widget.dragging { opacity: 0.4; }
.widget.drop-before { box-shadow: -3px 0 0 var(--orange); }

.widget-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.widget-handle {
    cursor: grab;
    color: var(--ink-3);
    opacity: 0.4;
    font-size: 15px;
    user-select: none;
    line-height: 1;
    padding: 2px;
    flex-shrink: 0;
    transition: opacity 0.15s;
}
.widget:hover .widget-handle { opacity: 1; }
.widget-handle:active { cursor: grabbing; }
.widget-title {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    color: var(--ink);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.widget-title a { color: inherit; text-decoration: none; }
.widget-title a:hover { color: var(--orange); }
.widget-controls { display: flex; gap: 3px; opacity: 0.4; transition: opacity 0.15s; flex-shrink: 0; }
.widget:hover .widget-controls, .widget-controls:focus-within { opacity: 1; }
.wsize {
    width: 22px; height: 22px;
    font-family: var(--font-display);
    font-size: 10px;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    background: var(--surface);
    color: var(--ink-3);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: background 0.15s, color 0.15s;
}
.wsize:hover { background: var(--tone-almond); color: var(--ink); }
.wsize.on { background: var(--charcoal); color: var(--almond); }
.widget-actions { display: flex; justify-content: flex-end; margin-bottom: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }
/* Ladekreis: der 2px-Ring ist der Spinner selbst, kein Rahmen */
.spinner {
    width: 11px; height: 11px;
    border: 2px solid rgba(173,189,214,0.3);
    border-top-color: var(--tone-blue-ink);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}
.hidden-row {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 6px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}
.hidden-label {
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-2);
}

/* ---- Widget-Inhalte je Größe ---- */
.todo-list.cols { column-width: 320px; column-gap: 36px; }
.todo-list.compact .todo { padding: 6px 0; font-size: 14px; }
.counters-body.cols { column-width: 260px; column-gap: 36px; }
.counters-body.cols .counter-row { break-inside: avoid; }

/* Zähler in S: gestapelte Kacheln statt breiter Zeilen */
.counter-tile {
    background: var(--surface);
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-bottom: 8px;
}
.counter-tile:last-child { margin-bottom: 0; }
.counter-tile-name {
    display: block;
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    color: var(--ink-2);
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.counter-tile-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.counter-tile .counter-value { font-size: 26px; min-width: 0; }
.counter-tile .counter-btn { width: 28px; height: 28px; font-size: 15px; }
.notes.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; max-height: none; }
.note-mini { list-style: none; margin: 0; padding: 0; }
.note-mini li {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 7px 0;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
    font-size: 14px;
    min-width: 0;
}
.note-mini li:last-child { border-bottom: none; }
.note-mini-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.more-link {
    background: none;
    border: none;
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0;
    color: var(--orange);
    cursor: pointer;
    padding: 6px 0 0;
}
.more-link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---- Content-Pipeline (Kanban) ---- */
.pipeline {
    display: grid;
    grid-template-columns: repeat(5, minmax(150px, 1fr));
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 4px;
}
@media (max-width: 1020px) { .panel-bento { grid-template-columns: 1fr; } }

.col-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.col-head h3 { margin: 0; }
/* Veränderung: positiv Moss, negativ Rot */
.delta.up { color: var(--tone-moss-ink); }
.delta.down { color: var(--danger); }
/* Sparkline: Strich in Blau-Tinte auf leichter Blau-Fläche */
.sparkline {
    width: 100%;
    height: 38px;
    color: var(--tone-blue-ink);
    background: rgba(59, 78, 107, 0.10);
    border-radius: 8px;
    padding: 5px 6px;
    box-sizing: border-box;
}

/* ============ Notizen ============ */
.notes { display: flex; flex-direction: column; gap: 12px; max-height: 420px; overflow-y: auto; padding-right: 4px; }
.note-card {
    background: var(--surface);
    border: none;
    border-radius: 12px;
    padding: 14px 16px;
}
.note-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.note-head strong { font-size: 15px; font-weight: 600; }
.note-items { list-style: none; margin: 0 0 10px; padding: 0; }
.note-items li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
}
.note-items li:last-child { border-bottom: none; }
.note-items a { color: var(--orange); font-weight: 600; text-decoration: none; word-break: break-all; }
.note-items a:hover { text-decoration: underline; text-underline-offset: 3px; }
.note-item-label { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
/* Ablauf-Hinweis: neutral, bald ablaufend Orange, abgelaufen Rot */
.expiry-badge {
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    border: none;
    border-radius: var(--r-pill);
    padding: 3px 9px;
    background: var(--tone-almond);
    color: var(--ink-2);
    white-space: nowrap;
}
.expiry-badge.warn { background: var(--tone-orange); color: var(--tone-orange-ink); }
.expiry-badge.dead { background: var(--tone-red); color: var(--tone-red-ink); text-decoration: line-through; }

/* ============ Zähler ============ */
.counter-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}
.counter-row:last-child { border-bottom: none; }
.counter-name { flex: 1; font-weight: 500; font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.counter-controls { display: flex; align-items: center; gap: 8px; }
.counter-btn {
    width: 34px; height: 34px;
    border-radius: 50%;
    border: none;
    background: var(--surface);
    color: var(--ink);
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    line-height: 1;
    box-shadow: none;
    transition: background 0.15s, color 0.15s, transform 0.1s;
}
.counter-btn:hover { background: var(--charcoal); color: var(--almond); }
.counter-btn:active { transform: translateY(1px); }
.counter-value {
    min-width: 50px;
    text-align: center;
    font-family: var(--font-title);
    font-size: 28px;
    font-weight: 400;
    line-height: 1;
    cursor: pointer;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}
/* Niedriger Bestand: Orange als Tonfläche statt nur als Textfarbe */
.counter-value.low {
    color: var(--tone-orange-ink);
    background: var(--tone-orange);
    border-radius: 8px;
    padding: 3px 8px;
}
