/**
 * calendar.css — Consolidated calendar styles for all MHZ calendar pages.
 * Replaces inline <style> blocks in agenda.php, relatagenda.php,
 * agenda_administrativo.php, and contratos.php (spec 99 §2 / issue 0088).
 */

/* ── Tipo event color classes ────────────────────────────────────────────── */
.agenda_verde   { background-color: #079069 !important; border-color: #079069 !important; }
.agenda_amarelo { background-color: #d97706 !important; border-color: #d97706 !important; }
.agenda_rosa    { background-color: #af4056 !important; border-color: #af4056 !important; }
.agenda_azul    { background-color: #3b4da1 !important; border-color: #3b4da1 !important; }
.agenda_cancelado { background-color: #6e6e6e !important; border-color: #6e6e6e !important; opacity: 0.7; }

/* ── Desktop FC cancelado styles ─────────────────────────────────────────── */
.fc-event.agenda_cancelado { background-color: #9a1a1a !important; border-color: #811313 !important; opacity: .8; }
.fc-event.agenda_cancelado .fc-event-title { text-decoration: line-through; }

/* ── Cancelled event styles (relatagenda) ────────────────────────────────── */
.fc-event.agenda-canceled .fc-event-title { text-decoration: line-through; opacity: 0.6; }
.fc-event.agenda-canceled { background-color: #4b5157 !important; border-color: #4b5157 !important; }

/* ── Cancelled-pill rules (relatagenda) ──────────────────────────────────── */
.fc-event.agenda-canceled-pill .fc-event-title {
    text-decoration: line-through;
    opacity: 0.85;
    font-style: italic;
}

/* ── FC cursor override ──────────────────────────────────────────────────── */
.fc-event { cursor: pointer !important; }

/* ── Blink animation (agenda.php CRM day marker) ─────────────────────────── */
@keyframes blink {
    0%,  100% { background-color: #eef3ff; }
    50%       { background-color: #dbeafe; }
}
.blink { animation: blink 1.4s infinite; }

/* ── Bolinha dots (legacy, kept for backward compat) ─────────────────────── */
.bolinha { display: none !important; }
.agenda_verde-dot   { background-color: red; }
.agenda_amarelo-dot { background-color: gold; }
.agenda_rosa-dot    { background-color: green; }
.agenda_azul-dot    { background-color: blue; }

/* ── FullCalendar toolbar suppress (custom strip replaces it) ────────────── */
.fc .fc-toolbar.fc-header-toolbar { display: none; }

/* ── Mobile calendar list (always hidden — FC grid shows on all sizes) ─── */
#mobile-list { display: none; }

/* ── Agenda mobile overrides (agenda.php) ────────────────────────────────── */
@media (max-width: 768px) {
    .fc-event .bolinha          { display: none !important; }
    td.fc-list-event-time       { display: none !important; }
    .fc-list-event-dot          { display: none !important; }
    .page-content               { padding-left: 0 !important; padding-right: 0 !important; }
    .page-container             { padding-left: 0 !important; padding-right: 0 !important; }
    .row                        { margin-left:  0 !important; margin-right:  0 !important; }
    .col-xl-12                  { padding-left: 0 !important; padding-right: 0 !important; }
    .card                       { border-radius: 0 !important; border-left: none !important;
                                  border-right: none !important; margin-bottom: 0 !important; }
    .card-body                  { padding: 4px 0 !important; }
    .fc .fc-toolbar             { padding-left: 0.75rem !important; padding-right: 0.75rem !important; }
    .fc-toolbar-chunk .fc-button-group .fc-prev-button,
    .fc-toolbar-chunk .fc-button-group .fc-next-button {
        background-color: transparent !important;
        border: 1px solid rgba(119,126,221,.5) !important;
        color: #777edd !important;
        box-shadow: none !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    .fc-toolbar-chunk .fc-button-group .fc-prev-button:hover,
    .fc-toolbar-chunk .fc-button-group .fc-next-button:hover {
        background-color: rgba(119,126,221,.1) !important;
    }

    /* ── Responsive FC day grid on mobile ──────────────────────────── */
    .fc .fc-daygrid-day-frame { min-height: 34px !important; }
    .fc .fc-daygrid-day-number { font-size: .7rem !important; padding: 2px 3px !important; }
    .fc-daygrid-event {
        font-size: .6rem !important;
        padding: 2px 3px !important;
        margin: 0 1px 1px !important;
        border-left-width: 2px !important;
        line-height: 1.1 !important;
    }
    .fc-daygrid-event .fc-event-title { font-size: .6rem !important; font-weight: 600 !important; }
    .fc-daygrid-day-events { min-height: auto !important; }
    .fc-scrollgrid { border-width: 0 !important; }
    .fc-col-header-cell { padding: 2px 0 !important; }
    .fc-col-header-cell-cushion { font-size: .65rem !important; padding: 2px !important; }
    .fc-daygrid-more-link { font-size: .6rem !important; }
}

/* ── Mobile list layout (agenda_administrativo, contratos — unused, kept for compat) ─ */

/* ── Upcoming sidebar (spec 98 §3, moved from agenda.php inline) ─────────── */
.agenda-cal-body {
    display: flex;
    gap: 0;
    align-items: stretch;
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
}
#calendar-wrap {
    flex: 1 1 0;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.agenda-upcoming-sidebar {
    width: 260px;
    flex: 0 0 260px;
    border-left: 1px solid var(--highdmin-border-color, #dee2e6);
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.agenda-cal-body[data-upcoming="closed"] .agenda-upcoming-sidebar {
    display: none;
}
.upcoming-header {
    padding: 10px 14px 8px;
    font-weight: 600;
    font-size: .85rem;
    border-bottom: 1px solid var(--highdmin-border-color, #dee2e6);
    position: sticky;
    top: 0;
    background: var(--highdmin-card-bg, #fff);
    z-index: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.upcoming-header-meta {
    display: flex;
    align-items: center;
    gap: 6px;
}
.btn-upcoming-collapse {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    color: var(--highdmin-body-color, #343a40);
    opacity: .6;
    line-height: 1;
    transition: opacity .15s, transform .2s;
}
.btn-upcoming-collapse:hover { opacity: 1; }
.agenda-cal-body[data-upcoming="closed"] .btn-upcoming-collapse i {
    transform: rotate(180deg);
    display: inline-block;
}
.upcoming-list {
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.upcoming-card {
    border-left: 4px solid #ccc;
    border-radius: 4px;
    padding: 6px 8px;
    background: var(--highdmin-card-bg, #fff);
    box-shadow: 0 1px 3px rgba(0,0,0,.07);
    cursor: pointer;
    transition: box-shadow .15s;
}
.upcoming-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.upcoming-card.agenda_verde   { border-left-color: #079069; }
.upcoming-card.agenda_amarelo { border-left-color: #d97706; }
.upcoming-card.agenda_rosa    { border-left-color: #af4056; }
.upcoming-card.agenda_azul    { border-left-color: #3b4da1; }
.upcoming-date {
    font-size: .72rem;
    font-weight: 700;
    color: var(--highdmin-body-color, #343a40);
    text-transform: uppercase;
    letter-spacing: .03em;
    margin-bottom: 2px;
}
.upcoming-location {
    font-size: .82rem;
    font-weight: 600;
    color: var(--highdmin-body-color, #343a40);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.upcoming-name {
    font-size: .77rem;
    color: var(--highdmin-body-secondary-color, #4b5157);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.upcoming-tipo {
    display: inline-block;
    font-size: .65rem;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 10px;
    background: rgba(0,0,0,.07);
    color: var(--highdmin-body-color, #343a40);
    margin-top: 3px;
}
.upcoming-day-header {
    font-size: .68rem;
    font-weight: 700;
    color: var(--highdmin-body-secondary-color, #4b5157);
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 6px 4px 2px;
    position: sticky;
    top: 0;
    background: var(--highdmin-body-bg, #f5f5f5);
    z-index: 1;
    margin-top: 4px;
}
.upcoming-status {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: .72rem;
    margin-top: 3px;
}
.upcoming-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.upcoming-dot.agenda_verde-dot   { background: #079069; }
.upcoming-dot.agenda_amarelo-dot { background: #d97706; }
.upcoming-dot.agenda_rosa-dot    { background: #af4056; }
.upcoming-dot.agenda_azul-dot    { background: #3b4da1; }
@media (max-width: 991px) {
    .agenda-upcoming-sidebar { display: none !important; }
    #upcoming-sidebar-tab { display: none !important; }
}

/* ── Mobile/tablet (<1280px): release full-height lock so page can scroll ─── */
@media (max-width: 1279px) {
    .calendar-fullheight-card {
        flex: none !important;
        overflow: visible !important;
    }
    .calendar-fullheight-card .card-body {
        overflow: visible !important;
        flex: none !important;
        min-height: unset !important;
    }
    .agenda-cal-body {
        overflow: visible !important;
        flex: none !important;
        min-height: unset !important;
        display: block !important;
    }
    #calendar-wrap {
        overflow: visible !important;
        flex: none !important;
        min-height: unset !important;
        display: block !important;
    }
    /* FC is inside a block (not flex) parent on mobile/tablet — undo the
       flex-grow rules that would collapse the view harness to 0 in an
       auto-height container. JS already sets height:'auto' via CalendarComponent. */
    .calendar-fullheight-card .fc.fc-media-screen {
        flex: none !important;
        overflow: visible !important;
        min-height: unset !important;
    }
    .calendar-fullheight-card .fc .fc-view-harness,
    .calendar-fullheight-card .fc .fc-view-harness-active {
        flex: none !important;
        min-height: unset !important;
        height: auto !important;
    }
}

/* ── Loading spinner wrapper ─────────────────────────────────────────────── */
#calendar-loading { padding: 2rem 0; text-align: center; }

/* ── Agenda-por-Contato modal event rows ─────────────────────────────────── */
.ca-event-row:hover { background: var(--highdmin-light, #f5f5f5); border-radius: 4px; }

/* ── Legend dots (contratos.php) ─────────────────────────────────────────── */
.cal-legend-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}
.contratos-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    font-size: 12px;
}
.contratos-legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 4px;
    flex-shrink: 0;
}
.contratos-legend-item {
    display: flex;
    align-items: center;
}

/* ── Event pill redesign (issue 0093): left-border accent, translucent bg ─── */
.fc-daygrid-event {
    border-radius: 4px !important;
    border-top: none !important;
    border-right: none !important;
    border-bottom: none !important;
    border-left-width: 4px !important;
    padding: 5px 6px !important;
    font-size: .85rem !important;
    font-weight: 700 !important;
}
.fc-daygrid-event.agenda_verde {
    background-color: rgba(7,144,105,.12) !important;
    border-left-color: #079069 !important;
    color: var(--highdmin-body-color) !important;
}
.fc-daygrid-event.agenda_amarelo {
    background-color: rgba(168,125,53,.12) !important;
    border-left-color: #d97706 !important;
    color: var(--highdmin-body-color) !important;
}
.fc-daygrid-event.agenda_rosa {
    background-color: rgba(175,64,86,.12) !important;
    border-left-color: #af4056 !important;
    color: var(--highdmin-body-color) !important;
}
.fc-daygrid-event.agenda_azul {
    background-color: rgba(59,77,161,.12) !important;
    border-left-color: #3b4da1 !important;
    color: var(--highdmin-body-color) !important;
}
.fc-daygrid-event.agenda_cancelado {
    background-color: rgba(154,26,26,.1) !important;
    border-left-color: #9a1a1a !important;
}
.fc-daygrid-event .fc-event-title {
    color: var(--highdmin-body-color) !important;
    font-weight: 700 !important;
}

/* ── Filter tipo chips (issue 0093) ──────────────────────────────────────── */
.filter-tipo-chip { display: inline-flex; align-items: center; gap: 5px; }
.chip-color-dot   { width: 10px; height: 10px; border-radius: 2px; display: inline-block; flex-shrink: 0; }
.filter-tipo-chip.active { font-weight: 600; }

/* ── Filter bar separator (issue 0093) ───────────────────────────────────── */
#agenda-filter-bar { border-bottom: 1px solid var(--highdmin-border-color, #dee2e6); padding-bottom: 8px; margin-bottom: 4px; }

/* ── Day cell number compact (issue 0093) ────────────────────────────────── */
.fc-daygrid-day-number { font-size: .8rem !important; padding: 3px 5px !important; }

/* ── Select2 Bootstrap-like overrides (relatagenda.php) ──────────────────── */
.select2-container .select2-selection--single {
    height: calc(1.5em + 0.75rem + 2px) !important;
    border: 1px solid #ced4da !important;
    border-radius: 0.375rem !important;
    background-color: #fff !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") !important;
    background-repeat: no-repeat !important;
    background-position: right 0.75rem center !important;
    background-size: 16px 12px !important;
    padding: 0 !important;
}
.select2-container .select2-selection--single .select2-selection__rendered {
    line-height: calc(1.5em + 0.75rem) !important;
    padding: 0 2.25rem 0 0.75rem !important;
    color: #212529 !important;
}
.select2-container .select2-selection--single .select2-selection__placeholder {
    color: #4b5157 !important;
}
.select2-container .select2-selection--single .select2-selection__arrow {
    display: none !important;
}
.select2-container--disabled .select2-selection--single {
    background-color: #e9ecef !important;
    cursor: not-allowed !important;
}
.select2-container--open .select2-selection--single {
    border-color: #86b7fe !important;
    box-shadow: 0 0 0 0.25rem rgba(13,110,253,.25) !important;
}

/* ── Full-height calendar layout (issue 0094 / fixed 0097) ──────────────── */
/* .page-content height/overflow intentionally NOT set here — those rules are
   scoped to each calendar page's inline <style> to avoid breaking other pages */

/* Card containing the calendar fills remaining space */
.calendar-fullheight-card {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}
.calendar-fullheight-card .card-body {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    padding: 8px 12px 0;
}

/* Month strip: flush full-width bar inside the full-height card */
.calendar-fullheight-card .crm-month-strip {
    border: none;
    border-radius: 0;
    border-bottom: 1px solid var(--highdmin-border-color, #dee2e6);
    padding: 4px 0;
    margin-left: -12px;
    margin-right: -12px;
    padding-left: 12px;
    padding-right: 12px;
    margin-bottom: 6px;
}

/* Month strip as direct sibling of calendar card (e.g. contratos.php layout) */
.page-container > .crm-month-strip {
    border: none;
    border-radius: 0;
    border-bottom: 1px solid var(--highdmin-border-color, #dee2e6);
    padding: 4px 0;
    margin-bottom: 6px;
}

/* FullCalendar fills its container when full-height context is active */
.calendar-fullheight-card .fc.fc-media-screen {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
}
.calendar-fullheight-card .fc .fc-view-harness {
    flex: 1 1 0 !important;
    min-height: 0 !important;
}

/* ── Upcoming-sidebar vertical tab (issue 0094, 0097) ────────────────────── */
.upcoming-sidebar-tab {
    flex: 0 0 28px;
    width: 28px;
    background: var(--highdmin-card-bg, #fff);
    border-left: 1px solid var(--highdmin-border-color, #dee2e6);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    transition: background .15s;
}
.upcoming-sidebar-tab:hover { background: var(--bs-tertiary-bg, #f3f4f6); }
/* Tab now shows a single «  character; label class removed */
.upcoming-sidebar-tab {
    font-size: 1rem;
    color: var(--highdmin-body-color, #343a40);
    user-select: none;
}
