/* CLEM calendar.css */
@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&display=swap');

.cal-grid-month {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 2px;
}
.cal-header-day {
    text-align: center;
    font-size: .78rem;
    font-weight: 600;
    color: #6b7280;
    padding: .4rem 0;
}
.cal-cell {
    min-height: 72px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: .3rem .4rem;
    background: #fff;
    font-size: .82rem;
    position: relative;
}
.cal-cell.other-month { background: #f9fafb; color: #d1d5db; }
.cal-cell.today { border-color: #1e3a5f; background: #eff6ff; }
.cal-day-num {
    font-weight: 600;
    font-size: .85rem;
    margin-bottom: .2rem;
    color: #374151;
}
.cal-cell.today .cal-day-num { color: #1e3a5f; }
.cal-icons { display: flex; gap: 2px; flex-wrap: wrap; margin-top: .2rem; }
.cal-icon { font-size: .85rem; cursor: default; }
/* Vista mes: conductors per sentit (Fase N) */
.cal-month-offers { margin-top: .2rem; font-size: .7rem; line-height: 1.3; }
.cal-month-sentit { display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem; margin-bottom: .15rem; }
.cal-month-sentit-anada   .cal-month-sentit-label { color: #1e3a5f; font-weight: 700; }
.cal-month-sentit-tornada .cal-month-sentit-label { color: #7c2d12; font-weight: 700; }
.cal-month-sentit-label { font-size: .72rem; margin-right: .1rem; }
.cal-month-driver { display: inline-flex; align-items: center; gap: .15rem; background: #f3f4f6; border-radius: 4px; padding: .05rem .3rem; font-size: .68rem; cursor: default; }
.cal-month-sentit-anada   .cal-month-driver { background: #eff6ff; }
.cal-month-sentit-tornada .cal-month-driver { background: #fff7ed; }
.cal-month-places { font-size: .65rem; color: #6b7280; }
.cal-month-empty { font-size: .7rem; color: #d1d5db; }

/* Vista setmanal (antiga, compat.) */
.cal-grid-week {
    display: grid;
    grid-template-columns: 60px repeat(7, 1fr);
    gap: 1px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}
.cal-week-header {
    background: #f3f4f6;
    text-align: center;
    padding: .5rem .3rem;
    font-size: .82rem;
    font-weight: 600;
    border-bottom: 2px solid #e5e7eb;
}
.cal-week-cell {
    min-height: 60px;
    padding: .3rem;
    border-bottom: 1px solid #f3f4f6;
    font-size: .8rem;
}

/* Vista setmanal rica */
.cal-week-rich {
    display: grid;
    grid-template-columns: repeat(7, minmax(160px, 1fr));
    gap: 6px;
    overflow-x: auto;
    padding-bottom: .5rem;
}
.cwr-col {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    min-width: 160px;
}
.cwr-col.cwr-today { border-color: #1e3a5f; }
.cwr-col.cwr-nolectiu { background: #f9fafb; opacity: .6; min-width: 0; }
.cwr-col.cwr-nolectiu .cwr-head {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-size: .68rem;
    padding: .5rem .15rem;
    text-align: center;
    white-space: nowrap;
    min-height: 80px;
}
.cwr-col.cwr-nolectiu .cwr-body { display: none; }
.cwr-head {
    background: #f3f4f6;
    text-align: center;
    padding: .4rem .3rem;
    font-size: .82rem;
    font-weight: 600;
    border-bottom: 1px solid #e5e7eb;
    line-height: 1.3;
}
.cwr-col.cwr-today .cwr-head { background: #1e3a5f; color: #fff; }
.cwr-date { font-size: .75rem; font-weight: 400; opacity: .8; }
.cwr-body {
    padding: .4rem .5rem;
    font-size: .78rem;
    display: flex;
    flex-direction: column;
}
.cwr-route-group {
    margin-bottom: .5rem;
    padding-bottom: .4rem;
    border-bottom: 1px dashed #e5e7eb;
}
.cwr-route-group:last-child { border-bottom: none; margin-bottom: 0; }
.cwr-route-title {
    font-weight: 600;
    font-size: .75rem;
    color: #1e3a5f;
    margin-bottom: .3rem;
    display: flex;
    align-items: center;
    gap: .3rem;
    flex-wrap: wrap;
}
.cwr-time { font-weight: 400; color: #6b7280; font-size: .72rem; }
.cwr-pub {
    display: flex;
    align-items: baseline;
    gap: .25rem;
    padding: .2rem .3rem;
    border-radius: 4px;
    margin-bottom: .15rem;
    flex-wrap: wrap;
    line-height: 1.4;
}
.cwr-pub.cwr-offer  { background: #f0fdf4; }
.cwr-pub.cwr-demand { background: #fff1f2; }
.cwr-pub.cwr-own    { outline: 1px solid #93c5fd; }
.cwr-type   { flex-shrink: 0; }
.cwr-who    { flex: 1; color: #374151; font-size: .75rem; }
.cwr-who em { color: #2563eb; font-style: normal; font-size: .7rem; }
.cwr-child  { color: #6b7280; }
.cwr-places { color: #6b7280; font-size: .72rem; white-space: nowrap; }
.cwr-btn-take {
    background: #1e3a5f;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: .15rem .4rem;
    font-size: .7rem;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}
.cwr-btn-take:hover { background: #2d5082; }

/* Vista diària */
.cal-day-view { padding: 1rem; }
.cal-day-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1e3a5f;
    margin-bottom: 1rem;
}
.cal-day-event {
    background: #eff6ff;
    border-left: 3px solid #1e3a5f;
    padding: .5rem .75rem;
    border-radius: 0 6px 6px 0;
    margin-bottom: .5rem;
    font-size: .88rem;
}

/* Grid d'ofertes per ruta — 3 columnes alineades entre registres */
.cwr-offers-table {
    display: grid;
    grid-template-columns: minmax(110px, max-content) 1fr auto;
    gap: 2px;
    margin: .3rem 0;
    border-radius: 7px;
    overflow: hidden;
}
.cwr-col-driver,
.cwr-col-children,
.cwr-col-action {
    padding: .4rem .55rem;
    display: flex;
    align-items: center;
    gap: .3rem;
    flex-wrap: wrap;
}
.cwr-col-driver {
    font-size: .8rem;
    font-weight: 600;
    color: #1e3a5f;
    white-space: nowrap;
    flex-wrap: nowrap;
    gap: .4rem;
}
.cwr-col-children { gap: .25rem; }
.cwr-col-action   { justify-content: flex-end; }

/* En vista setmana (columnes estretes) — reordenar verticalment */
.cal-week-rich .cwr-offers-table {
    grid-template-columns: 1fr;
}
.cal-week-rich .cwr-col-driver,
.cal-week-rich .cwr-col-children,
.cal-week-rich .cwr-col-action {
    white-space: normal;
}
.cal-week-rich .cwr-col-action { justify-content: flex-start; }

.cwr-offer-driver {
    font-size: .8rem;
    font-weight: 600;
    color: #1e3a5f;
    white-space: nowrap;
}
.cwr-own { color: #2563eb; font-style: normal; font-size: .72rem; }

/* Dots de places */
.cwr-seats-row {
    display: flex;
    align-items: center;
    gap: .25rem;
    flex-shrink: 0;
}
.cwr-seats-dots { display: flex; gap: 3px; align-items: center; }
.cwr-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.cwr-dot-occ  { background: #22c55e; }
.cwr-dot-free { background: #3b82f6; }
.cwr-seats-count {
    font-size: .72rem;
    color: #6b7280;
    white-space: nowrap;
}

/* Chips de fills */
.cwr-children-row {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
    margin-top: .35rem;
}
.cwr-child-chip {
    display: inline-block;
    padding: .1rem .45rem;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 500;
    cursor: default;
    white-space: nowrap;
}
.cwr-chip-reservada  { background: #16a34a; color: #fff; }
.cwr-chip-assignada  { background: #15803d; color: #fff; }

/* Bloc fills sense demanda */
.cwr-nodemanda-block {
    background: #fff;
    border: 1px solid #fca5a5;
    border-radius: 6px;
    padding: .4rem .6rem;
    margin: .3rem 0;
}
.cwr-nodemanda-title {
    color: #dc2626;
    font-size: .78rem;
    font-weight: 600;
    margin-bottom: .2rem;
}
.cwr-nodemanda-names { display: flex; flex-wrap: wrap; gap: .25rem; }
.cwr-nodemanda-name  { color: #dc2626; font-size: .78rem; }

/* Demandes sense cobertura */
.cwr-unmatched-block {
    background: #fee2e2;
    border-radius: 6px;
    padding: .4rem .6rem;
    margin: .3rem 0;
}
.cwr-no-cover { font-size: .75rem; color: #991b1b; margin-left: .3rem; }

/* Controls */
.cal-view-btn.active {
    background: #1e3a5f;
    color: #fff;
}

/* Amplada màxima ampliada per vista setmanal rica */
.clem-content:has(.cal-week-rich) { max-width: 1400px; }

/* Indicador scroll horitzontal — fade dret */
.cwr-scroll-wrap {
    position: relative;
}
.cwr-scroll-wrap::after {
    content: '';
    position: absolute;
    right: 0; top: 0; bottom: 0;
    width: 2.5rem;
    background: linear-gradient(to right, transparent, rgba(245,245,245,.95));
    pointer-events: none;
    z-index: 5;
    transition: opacity .2s;
}
.cwr-scroll-wrap.at-end::after {
    opacity: 0;
}

/* Llegenda */
.cal-legend {
    display: flex;
    gap: 1rem;
    font-size: .8rem;
    color: #6b7280;
    margin-top: .75rem;
    flex-wrap: wrap;
}
.cal-legend-item { display: flex; align-items: center; gap: .3rem; }

/* Vista dia — columnes anada / tornada */
.cwr-day-cols {
    display: flex;
    gap: .75rem;
    align-items: flex-start;
    flex-wrap: wrap;
}
.cwr-day-col {
    flex: 1 1 280px;
    min-width: 220px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}
.cwr-day-col-header {
    padding: .7rem 1rem .6rem;
    font-size: 1.6rem;
    font-weight: 400;
    font-family: 'Fredoka One', cursive;
    letter-spacing: .04em;
    line-height: 1;
}
.cwr-day-col-anada   { background: #bfdbfe; color: #1e3a5f; }
.cwr-day-col-tornada { background: #fed7aa; color: #7c2d12; }
.cwr-day-col-nodir   { background: #f3f4f6; color: #6b7280; }
.cwr-day-col-body    { padding: .5rem; }
.cwr-day-col-sub     { font-weight: 400; font-size: .52em; opacity: .8; margin-left: .35rem; font-family: sans-serif; letter-spacing: 0; vertical-align: middle; }

/* Placeholder per a rutes absents un dia (alineació vertical entre columnes) */
.cwr-route-placeholder {
    margin-bottom: .5rem;
    visibility: hidden;
}

/* Blocs anada/tornada dins la vista setmanal */
.cwr-tornada-block {
    border-top: 2px solid #fed7aa;
    margin-top: .4rem;
    padding-top: .3rem;
}
.cwr-block-label {
    display: inline-block;
    font-size: 1.1rem;
    font-weight: 400;
    font-family: 'Fredoka One', cursive;
    color: #1e3a5f;
    background: #dbeafe;
    border-radius: 99px;
    padding: .05rem .6rem .1rem;
    margin-bottom: .4rem;
    letter-spacing: .03em;
}
.cwr-block-label-tornada { color: #7c2d12; background: #fde68a; }

/* Botons ràpids +Oferta / +Demanda (vistes dia i setmana) */
.cwr-quick-btns {
    display: flex;
    gap: .3rem;
    margin-top: .4rem;
    padding-top: .3rem;
    border-top: 1px dashed #e5e7eb;
}
.cwr-quick-btn {
    font-size: .72rem;
    padding: .15rem .55rem;
    border: 1px solid #6b7280;
    border-radius: 5px;
    background: #f9fafb;
    color: #374151;
    cursor: pointer;
    transition: background .15s, color .15s;
    white-space: nowrap;
}
.cwr-quick-btn:hover    { background: #1e3a5f; color: #fff; border-color: #1e3a5f; }
.cwr-quick-btn-dem      { border-color: #7c2d12; color: #7c2d12; }
.cwr-quick-btn-dem:hover { background: #7c2d12; color: #fff; border-color: #7c2d12; }

/* Botons +Oferta/+Demanda significativament més grans a la vista dia */
.cwr-day-col .cwr-quick-btns {
    gap: .6rem;
    margin-top: .6rem;
    padding-top: .5rem;
}
.cwr-day-col .cwr-quick-btn {
    font-size: 1rem;
    padding: .55rem 1.3rem;
    border-radius: 7px;
    font-weight: 600;
    border-width: 1.5px;
}

/* Formulari inline eliminat (T325): els botons +Oferta/+Demanda obren el modal de publications.js */

/* Responsiu mòbil — vista mes */
@media (max-width: 600px) {
    .cal-cell {
        min-height: 44px;
        padding: .15rem .2rem;
        overflow: hidden;
    }
    .cal-day-num { font-size: .75rem; }
    .cal-month-offers {
        font-size: .58rem;
        line-height: 1.2;
        margin-top: .1rem;
    }
    .cal-month-sentit {
        flex-direction: column;
        gap: .04rem;
        margin-bottom: .08rem;
    }
    .cal-month-sentit-label { font-size: .6rem; }
    .cal-month-driver {
        display: flex;
        flex-wrap: wrap;
        width: 100%;
        max-width: 100%;
        overflow: hidden;
        padding: .02rem .15rem;
        font-size: .58rem;
        gap: .08rem;
    }
    .cal-month-places { font-size: .52rem; }
    .clem-phone-btn { font-size: .6rem !important; padding: 0 !important; }
}
