/* ═══════════════════════════════════════════════════════════════════════════
   Termin-Kalender Pro — ToDo Block Frontend View
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── CSS Custom Properties ────────────────────────────────────────────────── */
.ter-kal-todo-block-v2 {
    --tbv-radius:      10px;
    --tbv-border:      #e5e7eb;
    --tbv-surface:     #ffffff;
    --tbv-shadow:      0 1px 4px rgba(0,0,0,.08);
    --tbv-accent:      #FF3C00;
    --tbv-text-muted:  #6b7280;
    font-family: inherit;
    max-width: 800px;
}

/* ── Block Header (Titel + Edit-Link) ─────────────────────────────────────── */
.ter-kal-tbv-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.ter-kal-tbv-heading {
    margin: 0;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ter-kal-tbv-heading .dashicons {
    color: var(--tbv-accent);
}

/* ── Toolbar (Filter-Tabs + Sort + Print) ─────────────────────────────────── */
.ter-kal-tbv-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.ter-kal-tbv-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    flex: 1;
}

.ter-kal-tbv-tab {
    padding: 4px 14px;
    border: 1px solid var(--tbv-border);
    border-radius: 20px;
    background: #f9f9f9;
    cursor: pointer;
    font-size: .85rem;
    line-height: 1.5;
    transition: background .15s, color .15s, border-color .15s;
    white-space: nowrap;
}

.ter-kal-tbv-tab.is-active,
.ter-kal-tbv-tab:hover {
    background: var(--tbv-accent);
    color: #fff;
    border-color: var(--tbv-accent);
}

.ter-kal-tbv-sort {
    padding: 4px 8px;
    border: 1px solid var(--tbv-border);
    border-radius: 6px;
    font-size: .85rem;
    background: #f9f9f9;
    cursor: pointer;
}

.ter-kal-tbv-print {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border: 1px solid var(--tbv-border);
    border-radius: 6px;
    background: #f9f9f9;
    cursor: pointer;
    font-size: .85rem;
    margin-left: auto;
    transition: background .15s;
    white-space: nowrap;
}

.ter-kal-tbv-print:hover { background: #e5e7eb; }

/* ── Task List ────────────────────────────────────────────────────────────── */
.ter-kal-tbv-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ── Task Item ────────────────────────────────────────────────────────────── */
.ter-kal-tbv-item {
    background: var(--tbv-surface);
    border-radius: var(--tbv-radius);
    border-left: 4px solid var(--prio-color, #9ca3af);
    box-shadow: var(--tbv-shadow);
    overflow: hidden;
    transition: box-shadow .15s, transform .15s;
    /* Kein padding hier — kommt vom body */
}

.ter-kal-tbv-item:hover {
    box-shadow: 0 4px 14px rgba(0,0,0,.1);
    transform: translateY(-1px);
}

.ter-kal-tbv-item.is-done { opacity: .65; }

/* ── Task Body (voller Inhalt) ────────────────────────────────────────────── */
.ter-kal-tbv-body {
    padding: 12px 16px;
    min-width: 0;     /* KRITISCH: flex-child darf schrumpfen */
}

/* ─────────────────────────────────────────────────────────────────────────────
   ZEILE 1 — Punkt · Titel · Badge · Datum
   ────────────────────────────────────────────────────────────────────────── */
.ter-kal-tbv-item-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;          /* umbrechen bei schmalem Viewport */
    gap: 6px;
    margin-bottom: 0;
}

/* Farbpunkt */
.ter-kal-tbv-prio-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Titel */
.ter-kal-tbv-title {
    font-weight: 600;
    font-size: .9375rem;
    flex: 1;
    min-width: 120px;         /* bricht erst um, wenn < 120 px übrig */
    min-width: 0;             /* text-overflow aktiv */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ter-kal-tbv-title.is-done {
    text-decoration: line-through;
    color: #9ca3af;
}

/* Priority Badge */
.ter-kal-tbv-badge {
    font-size: .7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
    flex-shrink: 0;
}

.prio-badge-new    { background: #dbeafe; color: #1d4ed8; }
.prio-badge-high   { background: #fee2e2; color: #b91c1c; }
.prio-badge-normal { background: #fef3c7; color: #92400e; }
.prio-badge-low    { background: #d1fae5; color: #065f46; }
.prio-badge-done   { background: #f3f4f6; color: #6b7280; }

/* Due Date — direkt in Zeile 1 */
.ter-kal-tbv-due {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: .8rem;
    color: var(--tbv-text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.ter-kal-tbv-due .dashicons {
    font-size: .9rem;
    width: .9rem;
    height: .9rem;
    line-height: 1;
}

.ter-kal-tbv-due.is-overdue {
    color: #b91c1c;
    font-weight: 600;
}

/* ─────────────────────────────────────────────────────────────────────────────
   ZEILE 2 — Beschreibung
   ────────────────────────────────────────────────────────────────────────── */
.ter-kal-tbv-desc {
    margin: 5px 0 0;
    font-size: .875rem;
    color: #374151;
    line-height: 1.55;
    /* text kann umbrechen */
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word;
}

/* ─────────────────────────────────────────────────────────────────────────────
   ZEILE 3 — Meta (Schedule-Link)
   ────────────────────────────────────────────────────────────────────────── */
.ter-kal-tbv-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.ter-kal-tbv-schedule {
    font-size: .8rem;
}

.ter-kal-tbv-schedule a {
    color: #3b82f6;
    text-decoration: none;
}

.ter-kal-tbv-schedule a:hover { text-decoration: underline; }

/* ── Loading / Empty ──────────────────────────────────────────────────────── */
.ter-kal-tbv-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #666;
    font-size: .9rem;
    padding: 12px 0;
}

.ter-kal-tbv-empty {
    color: #9ca3af;
    font-size: .9rem;
    padding: 12px 0;
}

.ter-kal-tbv-loading[hidden],
.ter-kal-tbv-empty[hidden] { display: none; }

/* ── Action Link (Admin-Edit / Login) ─────────────────────────────────────── */
.ter-kal-tbv-action-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: .85rem;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 6px;
    text-decoration: none;
    background: #f0f0f0;
    color: #333;
    border: 1px solid #ddd;
    transition: background .15s, color .15s;
    white-space: nowrap;
}

.ter-kal-tbv-action-link:hover {
    background: var(--tbv-accent);
    color: #fff;
    border-color: var(--tbv-accent);
}

.ter-kal-tbv-action-link .dashicons { color: #666; }
.ter-kal-tbv-action-link:hover .dashicons { color: #fff; }

/* ── Login-Gate ───────────────────────────────────────────────────────────── */
.ter-kal-tbv-gated { padding: 32px 24px; text-align: center; }

.ter-kal-tbv-login-notice {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 32px 40px;
    border: 1px solid var(--tbv-border);
    border-radius: 12px;
    background: #f9fafb;
}

.ter-kal-tbv-login-icon { font-size: 2.5rem; line-height: 1; }
.ter-kal-tbv-login-notice p { margin: 0; color: #374151; font-size: 1rem; }

.ter-kal-tbv-login-btn {
    display: inline-block;
    padding: 8px 24px;
    background: var(--tbv-accent);
    color: #fff;
    border-radius: 6px;
    text-decoration: none;
    font-size: .9rem;
    font-weight: 600;
    transition: background .15s;
}

.ter-kal-tbv-login-btn:hover { background: #d93200; color: #fff; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 480px) {

    /* Toolbar: Tabs volle Breite, Sort + Print darunter */
    .ter-kal-tbv-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .ter-kal-tbv-tabs { width: 100%; }

    .ter-kal-tbv-print { margin-left: 0; }

    /* Zeile 1: Titel darf umbrechen statt abschneiden */
    .ter-kal-tbv-item-header {
        flex-direction: column;    /* Punkt+Titel oben, Badge+Datum darunter */
        align-items: flex-start;
    }

    /* Punkt + Titel nebeneinander halten */
    .ter-kal-tbv-item-header > .ter-kal-tbv-prio-dot,
    .ter-kal-tbv-item-header > .ter-kal-tbv-title {
        /* bleiben in der ersten Reihe */
    }

    .ter-kal-tbv-title {
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        flex: 1 1 100%;         /* volle Breite nach Punkt */
    }
}

/* ── Print ────────────────────────────────────────────────────────────────── */
@media print {
    .ter-kal-tbv-toolbar,
    .ter-kal-tbv-block-header .ter-kal-tbv-action-link,
    .ter-kal-tbv-print {
        display: none !important;
    }

    .ter-kal-tbv-item {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}
