/*
 * The agenda. Same approach as board.css: its own tokens per mode, no
 * Tailwind build in the panel. Accent is PedalPro cyan.
 */
.crm-agenda {
    --surface: #ffffff;
    --surface-raised: #f8fafc;
    --border: #e5e7eb;
    --line: #f1f5f9;
    --text: #111827;
    --text-muted: #6b7280;
    --accent: #00a5df;
    --open: #e6f6fc;
    --open-edge: #b3e4f6;
    --off: #f3f4f6;
    --radius: 8px;
    --hour: 52px;

    color: var(--text);
}

.dark .crm-agenda {
    --surface: #0f1115;
    --surface-raised: #171a21;
    --border: #272b34;
    --line: #1c2028;
    --text: #e5e7eb;
    --text-muted: #9099ab;
    --open: rgba(0, 165, 223, 0.10);
    --open-edge: rgba(0, 165, 223, 0.35);
    --off: #1f232b;
}

/* ── Toolbar ─────────────────────────────────────────────────────────── */

.crm-agenda__toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.crm-agenda__spacer { flex: 1 1 auto; }

.crm-agenda .crm-field {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 13px;
    padding: 6px 10px;
    min-height: 34px;
}

.crm-agenda__nav { display: flex; gap: 4px; }

.crm-agenda__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.crm-agenda__btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.crm-agenda__btn:disabled { opacity: 0.45; cursor: default; }
.crm-agenda__btn--accent { border-color: var(--accent); color: var(--accent); text-decoration: none; }

.crm-agenda__range { font-size: 14px; font-weight: 600; }

.crm-agenda__legend {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.crm-agenda__swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    margin-left: 8px;
}

.crm-agenda__swatch--open { background: var(--open); border: 1px solid var(--open-edge); }
.crm-agenda__swatch--tentative { background: repeating-linear-gradient(45deg, var(--accent) 0 3px, transparent 3px 6px); border: 1px solid var(--accent); }
.crm-agenda__swatch--off { background: repeating-linear-gradient(-45deg, var(--off) 0 3px, var(--border) 3px 5px); }

/* ── Grid ────────────────────────────────────────────────────────────── */

.crm-agenda__grid {
    display: grid;
    grid-template-columns: 56px repeat(7, minmax(110px, 1fr));
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    transition: opacity 0.15s;
}

.crm-agenda__grid--loading { opacity: 0.5; }

.crm-agenda__corner,
.crm-agenda__dayhead {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.crm-agenda__dayhead {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 6px;
    padding: 10px 4px;
    border-left: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.crm-agenda__dayhead strong { font-size: 18px; color: var(--text); }

.crm-agenda__dayhead--today strong {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
}

.crm-agenda__gutter {
    display: grid;
    grid-auto-rows: var(--hour);
    font-size: 11px;
    color: var(--text-muted);
    text-align: right;
}

.crm-agenda__gutter span { padding: 2px 8px 0 0; transform: translateY(-8px); }
.crm-agenda__gutter span:first-child { transform: none; }

.crm-agenda__day {
    position: relative;
    height: calc(var(--hours) * var(--hour));
    border-left: 1px solid var(--border);
    background-image: repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px var(--hour));
}

.crm-agenda__day--today { background-color: color-mix(in srgb, var(--accent) 3%, transparent); }

.crm-agenda__block {
    position: absolute;
    inset-inline: 0;
    background: var(--open);
    border-left: 3px solid var(--open-edge);
}

.crm-agenda__off {
    position: absolute;
    inset-inline: 0;
    z-index: 1;
    background: repeating-linear-gradient(-45deg, var(--off) 0 6px, var(--surface-raised) 6px 12px);
    font-size: 11px;
    color: var(--text-muted);
    padding: 4px 6px;
    overflow: hidden;
}

.crm-agenda__item {
    position: absolute;
    inset-inline: 4px;
    z-index: 2;
    display: block;
    overflow: hidden;
    padding: 3px 8px;
    border-radius: 6px;
    border-left: 3px solid var(--item);
    background: color-mix(in srgb, var(--item) 16%, var(--surface));
    color: var(--text);
    font-size: 12px;
    line-height: 1.3;
    text-decoration: none;
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.06);
    transition: transform 0.1s, box-shadow 0.1s;
}

.crm-agenda__item:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgb(0 0 0 / 0.12); z-index: 4; }

.crm-agenda__item--tentative {
    background: repeating-linear-gradient(45deg, color-mix(in srgb, var(--item) 9%, var(--surface)) 0 6px, var(--surface) 6px 12px);
    border-left-style: dashed;
}

/* Time and name on one line, so a half-hour appointment still says who. */
.crm-agenda__time { font-weight: 600; font-variant-numeric: tabular-nums; margin-right: 6px; }
.crm-agenda__title { font-weight: 500; }
.crm-agenda__sub { display: block; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.crm-agenda__now {
    position: absolute;
    inset-inline: 0;
    z-index: 5;
    height: 2px;
    background: #ef4444;
}

.crm-agenda__now::before {
    content: '';
    position: absolute;
    left: -4px;
    top: -3px;
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #ef4444;
}

.crm-agenda__empty {
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-muted);
}
