/* ==========================================================================
   CraftX ERP — Scheduler surface utilities
   Layout primitives specific to the calendar / appointment surface.
   Token-only: all values reference vars defined in app.css / cx-widgets.css.

   Namespace: .cx-scheduler-*
   This file augments the global widget kit (.card, .chip, .btn, .list-row,
   .data-table from cx-widgets.css) with patterns the Scheduler reuses
   across the main calendar shell, sidebar tabs, quick-info popups and the
   appointment dialogs.

   Out of scope for this file: Syncfusion `SfSchedule` internal cell / event
   styling — those overrides live in cx-syncfusion-overrides.css.
   ========================================================================== */

/* ── Page chrome ───────────────────────────────────────────────────────── */

/* Scheduler runs full-bleed so the calendar can claim the full viewport.
   The shell strips `.erp-content` padding when it sees `.full-bleed`. */
.cx-scheduler-page {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: transparent;
    overflow: hidden;
}

/* Optional title strip — currently unused on the main calendar (Syncfusion
   provides its own toolbar) but retained for sub-pages and dialogs that
   want the same Bricolage display title as Contacts / HR. */
.cx-scheduler-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 16px 24px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.cx-scheduler-page-header .cx-scheduler-page-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: var(--fw-bold, 700);
    color: var(--cx-text-primary);
    letter-spacing: -0.02em;
    margin: 0 0 0.2rem;
}

.cx-scheduler-page-header .cx-scheduler-page-subtitle {
    font-family: var(--font-sans);
    color: var(--cx-text-muted);
    margin: 0;
    font-size: 0.9rem;
}

.cx-scheduler-page-header .cx-scheduler-header-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ── Filter pills (sidebar tabs) ───────────────────────────────────────
   The Scheduler sidebar uses a row of pill-style tab buttons (Aufträge /
   Kontakte / Team) with a count badge. The base styling lives inline in
   SchedulerPage.razor via `.tab-btn`; this layer adds the active modifier
   so the warm carpenter palette wins consistently. */
.cx-scheduler-filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    font-size: 12.5px;
    font-weight: var(--fw-semibold, 600);
    color: var(--cx-text-secondary);
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s var(--ease, ease), color 0.15s var(--ease, ease), border-color 0.15s var(--ease, ease);
}

.cx-scheduler-filter-pill:hover {
    color: var(--cx-text-primary);
    background: rgba(28, 25, 21, 0.04);
}

.cx-scheduler-filter-pill.is-active {
    color: var(--cx-primary);
    background: var(--cx-primary-soft);
    border-color: rgba(184, 96, 31, 0.20);
}

.cx-scheduler-filter-pill .cx-scheduler-filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 10.5px;
    font-weight: var(--fw-bold, 700);
    border-radius: var(--radius-pill);
    background: rgba(28, 25, 21, 0.06);
    color: var(--cx-text-secondary);
}

.cx-scheduler-filter-pill.is-active .cx-scheduler-filter-count {
    background: rgba(184, 96, 31, 0.18);
    color: var(--cx-primary);
}

/* ── Empty state ───────────────────────────────────────────────────────
   Friendly "Keine Aufträge / Kontakte / Mitarbeiter gefunden" placeholders
   inside the sidebar tabs. Consistent with the carpenter look — soft sand
   plate, copper accent icon, muted helper line. */
.cx-scheduler-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 36px 20px;
    color: var(--cx-text-muted);
    text-align: center;
}

.cx-scheduler-empty .cx-scheduler-empty-ico {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-lg);
    display: grid;
    place-items: center;
    background: var(--cx-primary-soft);
    color: var(--cx-primary);
    font-size: 20px;
    margin-bottom: 4px;
}

.cx-scheduler-empty .cx-scheduler-empty-title {
    font-size: 13.5px;
    font-weight: var(--fw-semibold, 600);
    color: var(--cx-text-secondary);
    margin: 0;
}

.cx-scheduler-empty .cx-scheduler-empty-sub {
    font-size: 12px;
    color: var(--cx-text-muted);
    margin: 0;
    max-width: 220px;
    line-height: 1.4;
}

/* ── Connection / status chip ──────────────────────────────────────────
   SignalR offline / reconnecting indicator that floats next to the sidebar
   tabs. Reuses the chip palette so warning / danger tones stay consistent. */
.cx-scheduler-connection {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: var(--fw-bold, 700);
    letter-spacing: 0.02em;
    text-transform: uppercase;
    white-space: nowrap;
}

.cx-scheduler-connection.is-offline {
    background: color-mix(in srgb, var(--cx-warning) 16%, white);
    color: var(--cx-warning);
}

.cx-scheduler-connection.is-reconnecting {
    background: color-mix(in srgb, var(--cx-info) 14%, white);
    color: var(--cx-info);
}

.cx-scheduler-connection .cx-scheduler-connection-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* ── Quick-info / dialog footer buttons ─────────────────────────────────
   Bridge the legacy `.footer-btn.delete-btn` / `.footer-btn.edit-btn`
   used inside SchedulerPage's QuickInfo popup to the design-system btn
   sizing so they read as the same control as the AppointmentEditor's
   action bar. The colors already come from tokens — this just normalizes
   shape and shadow with the global .btn family. */
.cx-scheduler-footer-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    background: var(--paper-2, var(--paper-2));
    border-top: 1px solid var(--cx-hairline-soft);
}

/* ── QuickInfo Status-Schnellaktionen ───────────────────────────────────
   Erledigt / Absagen / Wieder öffnen buttons in the QuickInfo footer. The
   popup renders at body level, so these live in the global (unscoped) sheet
   next to the delete/edit bridge above. Tinted-outline treatment keeps them
   visually secondary to the primary Bearbeiten action. */
.footer-btn.status-btn {
    background: transparent;
    font-weight: var(--fw-medium, 600);
}

.footer-btn.status-done-btn {
    color: var(--cx-success);
    border: 1px solid color-mix(in srgb, var(--cx-success) 40%, transparent);
}

.footer-btn.status-done-btn:hover {
    background: color-mix(in srgb, var(--cx-success) 12%, transparent);
}

.footer-btn.status-cancel-btn {
    color: var(--cx-danger);
    border: 1px solid color-mix(in srgb, var(--cx-danger) 40%, transparent);
}

.footer-btn.status-cancel-btn:hover {
    background: color-mix(in srgb, var(--cx-danger) 12%, transparent);
}

.footer-btn.status-reopen-btn {
    color: var(--cx-text-secondary);
    border: 1px solid var(--cx-hairline-soft);
}

.footer-btn.status-reopen-btn:hover {
    background: color-mix(in srgb, var(--cx-text-secondary) 10%, transparent);
}

/* ── Mobile ────────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
    .cx-scheduler-page-header {
        padding: 12px 16px;
    }

    .cx-scheduler-page-header .cx-scheduler-page-title {
        font-size: 1.25rem;
    }

    .cx-scheduler-empty {
        padding: 24px 16px;
    }
}

/* ── Termin-Status auf dem Kalender-Block ─────────────────────────────────
   Set by SchedulerPage.OnEventRendered. Abgesagt: muted + durchgestrichen;
   Erledigt: leicht gedimmt mit Häkchen vor dem Titel. */

.e-schedule .e-appointment.appointment-status-cancelled {
    opacity: 0.55;
}

.e-schedule .e-appointment.appointment-status-cancelled .e-subject {
    text-decoration: line-through;
}

.e-schedule .e-appointment.appointment-status-done {
    opacity: 0.8;
}

.e-schedule .e-appointment.appointment-status-done .e-subject::before {
    content: "\2713\00a0"; /* ✓ + nbsp */
    font-weight: 700;
}

/* ── Plantafel (Timeline-Resource-Ansicht) ────────────────────────────────
   Mitarbeiter als Zeilen, Zeit horizontal. Templates gerendert von
   SchedulerPage (PlantafelEventTemplate / PlantafelResourceHeaderTemplate). */

.e-schedule .e-timeline-view .e-resource-left-td,
.e-schedule .e-timeline-month-view .e-resource-left-td {
    width: 240px;
    vertical-align: middle;
}

.e-schedule .e-timeline-view .e-resource-cells,
.e-schedule .e-timeline-month-view .e-resource-cells {
    padding: 0;
}

.plantafel-resource {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    min-height: 48px;
}

.plantafel-resource .pr-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.plantafel-resource .pr-avatar-unassigned {
    background: var(--light-gray, #eef1f4);
    font-size: 15px;
}

.plantafel-resource .pr-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.plantafel-resource .pr-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--cx-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.plantafel-resource .pr-sub {
    font-size: 11px;
    color: var(--cx-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.plantafel-resource .availability-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.plantafel-resource .availability-dot.available { background: var(--cx-success, #22c55e); }
.plantafel-resource .availability-dot.partiallybooked { background: var(--cx-warning, #f59e0b); }
.plantafel-resource .availability-dot.fullybooked { background: var(--cx-danger, #ef4444); }
.plantafel-resource .availability-dot.onleave { background: var(--cx-info, #3b82f6); }

/* Kompakter, einzeiliger Termin-Balken */
.e-schedule .e-timeline-view .e-appointment {
    border-radius: 6px;
}

.plantafel-event {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 100%;
    padding: 4px 8px;
    font-size: 12px;
    line-height: 1.2;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
}

.plantafel-event .pe-time {
    font-weight: 700;
    flex-shrink: 0;
}

.plantafel-event .pe-subject {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
}

.plantafel-event .pe-customer {
    opacity: 0.85;
    overflow: hidden;
    text-overflow: ellipsis;
}

.plantafel-event .pe-travel {
    margin-left: auto;
    flex-shrink: 0;
    font-size: 11px;
    background: rgba(0, 0, 0, 0.18);
    border-radius: 10px;
    padding: 1px 6px;
}

/* Urlaub/Abwesenheit: Farbe kommt vom .virtual-leave-block-Styling, nicht weiß erzwingen */
.plantafel-event-leave {
    color: inherit;
}

/* ── Plantafel · Woche: Stunden-Raster mit horizontalem Scrollen ──────────
   Feste Zellbreite pro 60-Min-Slot; die Scope-Klasse .plantafel-week setzt
   SchedulerPage nur in der TimelineWeek-Ansicht (Tagesansicht bleibt fluide). */

.plantafel-week .e-timeline-view .e-date-header-wrap table col,
.plantafel-week .e-timeline-view .e-content-wrap table col {
    width: 48px;
}

/* ── Virtuelle Fahrt-Blöcke (Routenzeit aus Google Maps) ──────────────────
   Dezent: halbtransparente Schraffur in der Mitarbeiterfarbe, kein Rahmen,
   kein eigener Titel — der Block endet exakt am Terminbeginn und hängt optisch
   am Termin (Rundung nur an der abgewandten Seite). Die Minuten stehen im
   Termin selbst ("🚗 x Min.") und im Tooltip des Blocks.
   --travel-color wird pro Block in OnEventRendered gesetzt. */

.e-schedule .e-appointment.travel-segment-block {
    background: repeating-linear-gradient(
        135deg,
        color-mix(in srgb, var(--travel-color, #94a3b8) 22%, transparent) 0 4px,
        transparent 4px 9px) !important;
    border: none !important;
    box-shadow: none !important;
    opacity: 0.85;
    cursor: default;
}

/* Plantafel (Timeline): Fahrt liegt links vom Termin → rechts bündig */
.e-schedule .e-timeline-view .e-appointment.travel-segment-block {
    border-radius: 6px 0 0 6px !important;
}

.travel-event-template {
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    height: 100%;
    padding: 2px 4px;
    overflow: hidden;
}

.travel-event-template .travel-event-icon,
.plantafel-event-travel .pe-icon {
    font-size: 10px;
    line-height: 1;
    opacity: 0.55;
}

.plantafel-event-travel {
    justify-content: flex-end;
    padding-right: 4px;
}

/* Toolbar-Datumsbereich (inkl. KW) */
.e-schedule .cx-date-range {
    font-weight: 600;
    white-space: nowrap;
}
