/* Widget reutilizable para agendar citas — calendario + horarios + formulario.
   Usado por tramitar_credito.php, deseo_vender.php y tramites_legales.php
   vía Layouts/widget_agendar_cita.php. Clases prefijadas "cw-" para no
   colisionar con los estilos propios de cada página. */

.cw-widget {
    display: flex;
    flex-wrap: wrap;
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 22px 55px rgba(0, 0, 0, .18);
    max-width: 900px;
    margin: 0 auto;
}

.cw-panel {
    box-sizing: border-box;
    padding: 30px 26px;
}

/* ── Panel izquierdo: calendario ── */
.cw-panel-calendar {
    flex: 1 1 360px;
    min-width: 300px;
    background: linear-gradient(160deg, #5f2580, #74319b 55%, #8a3fb0);
    color: #fff;
}

.cw-calendar-header-info {
    text-align: center;
    margin-bottom: 22px;
}

.cw-avatar {
    width: 56px;
    height: 56px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .14);
    border: 1px solid rgba(255, 255, 255, .3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fff;
}

.cw-heading {
    color: #fff;
    font-size: 19px;
    font-weight: 800;
    margin: 0 0 8px;
    line-height: 1.35;
}

.cw-subtitle {
    color: rgba(255, 255, 255, .85);
    font-size: 13px;
    line-height: 1.6;
    margin: 0;
}

.cw-month-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.cw-month-btn {
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .25);
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s ease;
}

.cw-month-btn:hover {
    background: rgba(255, 255, 255, .24);
}

.cw-month-btn:disabled {
    opacity: .35;
    cursor: not-allowed;
}

.cw-month-label {
    font-size: 15px;
    font-weight: 700;
    text-transform: capitalize;
    letter-spacing: .3px;
}

.cw-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .3px;
    color: rgba(255, 255, 255, .68);
    margin-bottom: 6px;
}

.cw-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    row-gap: 4px;
}

.cw-day {
    position: relative;
    background: none;
    border: none;
    color: rgba(255, 255, 255, .92);
    font-size: 13px;
    font-weight: 600;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    width: 34px;
    transition: background .15s ease, color .15s ease;
}

.cw-day:hover:not(:disabled):not(.cw-day-selected) {
    background: rgba(255, 255, 255, .18);
}

.cw-day-outside {
    color: rgba(255, 255, 255, .28);
    font-weight: 400;
}

.cw-day:disabled {
    color: rgba(255, 255, 255, .28);
    cursor: not-allowed;
}

.cw-day-selected {
    background: #fff;
    color: #5f2580 !important;
    font-weight: 800;
}

.cw-day-today:not(.cw-day-selected) {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .55);
}

/* ── Panel derecho: horarios / formulario ── */
.cw-panel-right {
    flex: 1 1 320px;
    min-width: 280px;
    background: #fff;
    display: flex;
    flex-direction: column;
}

.cw-duration-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: #888;
    margin-bottom: 8px;
}

.cw-duration-pill {
    display: inline-block;
    background: #f5f0f9;
    color: #74319b;
    font-size: 13px;
    font-weight: 700;
    padding: 8px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.cw-slots-heading {
    font-size: 16px;
    font-weight: 800;
    color: #2b2b2b;
    margin-bottom: 4px;
}

.cw-timezone {
    font-size: 12px;
    color: #74319b;
    font-weight: 600;
    margin-bottom: 16px;
}

.cw-slots-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 320px;
    overflow-y: auto;
    padding-right: 4px;
}

.cw-slots-empty {
    font-size: 13px;
    color: #888;
    line-height: 1.6;
    margin: 0;
}

.cw-slot-btn {
    display: block;
    width: 100%;
    text-align: center;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 600;
    color: #2b2b2b;
    cursor: pointer;
    transition: border-color .2s ease, background .2s ease, color .2s ease;
}

.cw-slot-btn:hover {
    border-color: #74319b;
    background: #f9f4fd;
    color: #74319b;
}

.cw-slot-btn:disabled {
    background: #f7f7f7;
    color: #bbb;
    border-color: #eee;
    cursor: not-allowed;
    text-decoration: line-through;
}

/* ── Formulario de datos ── */
.cw-back-link {
    background: none;
    border: none;
    color: #74319b;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    padding: 0;
    margin-bottom: 16px;
}

.cw-selected-slot {
    background: #f5f0f9;
    color: #5f2580;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 18px;
}

.cw-field {
    margin-bottom: 14px;
}

.cw-field label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #555;
    text-transform: uppercase;
    letter-spacing: .3px;
    margin-bottom: 5px;
}

.cw-required {
    color: #d92d20;
    font-weight: 800;
}

.cw-optional {
    text-transform: none;
    font-weight: 400;
    color: #999;
}

.cw-input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #ddd;
    border-radius: 10px;
    height: 46px;
    padding: 10px 14px;
    font-size: 14px;
    color: #1f2937;
    transition: border-color .2s ease;
}

.cw-input:focus {
    outline: none;
    border-color: #74319b;
    box-shadow: 0 0 0 3px rgba(116, 49, 155, .10);
}

.cw-textarea {
    height: auto;
    min-height: 80px;
    padding-top: 12px;
    resize: vertical;
}

.cw-input.cw-input-error {
    border-color: #d92d20;
    box-shadow: 0 0 0 3px rgba(217, 45, 32, .08);
}

.cw-field-error {
    display: none;
    margin-top: 6px;
    font-size: 12px;
    color: #d92d20;
    font-weight: 600;
}

.cw-submit-btn {
    display: block;
    width: 100%;
    background: #f7941d;
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 14px 20px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(247, 148, 29, .28);
    transition: transform .2s ease;
    margin-top: 6px;
}

.cw-submit-btn:hover {
    transform: translateY(-2px);
}

.cw-submit-btn:disabled {
    opacity: .75;
    cursor: not-allowed;
    transform: none;
}

/* ── Alertas / confirmación ── */
.cw-alert {
    display: none;
    margin-bottom: 16px;
    padding: 13px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.5;
    background: #fff4f4;
    color: #b42318;
    border: 1px solid #f3c7c7;
}

.cw-success {
    display: none;
    margin-bottom: 16px;
    padding: 16px 18px;
    border-radius: 12px;
    background: #ecfdf3;
    border: 1px solid #abefc6;
    color: #027a48;
    font-size: 14px;
    line-height: 1.6;
    font-weight: 600;
}

/* ── Responsive ── */
@media (max-width: 767px) {
    .cw-widget {
        flex-direction: column;
        border-radius: 16px;
    }

    .cw-panel {
        padding: 24px 20px;
    }

    .cw-slots-list {
        max-height: 260px;
    }
}

/* ── Variante compacta ──────────────────────────────────────────
   3 pasos apilados (fecha -> horario -> datos), un panel visible a
   la vez. Pensada para caber en la columna lateral de una ficha de
   propiedad, tanto en escritorio como en móvil. Misma lógica JS y
   los mismos hooks "data-cw-*" que la variante completa: solo cambia
   qué panel se muestra en cada momento y el tamaño de los elementos. */
.cw-widget.cw-compact {
    display: block;
    width: 100%;
    max-width: 100%;
    border-radius: 16px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .10);
}

.cw-steps {
    display: none;
}

.cw-compact .cw-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
    padding: 14px 16px 0;
    background: linear-gradient(160deg, #5f2580, #74319b 55%, #8a3fb0);
    font-size: 10.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .3px;
}

.cw-compact .cw-step-dot {
    color: rgba(255, 255, 255, .55);
    transition: color .2s ease, opacity .2s ease;
}

.cw-compact .cw-step-sep {
    color: rgba(255, 255, 255, .3);
}

.cw-compact .cw-step-dot-active {
    color: #ffd76b;
}

.cw-compact .cw-step-dot-done {
    color: rgba(255, 255, 255, .9);
}

.cw-compact .cw-panel {
    width: 100%;
    box-sizing: border-box;
    padding: 18px 18px 22px;
}

.cw-compact .cw-panel-calendar,
.cw-compact .cw-panel-right {
    flex: none;
    min-width: 0;
    width: 100%;
}

.cw-compact .cw-avatar {
    width: 42px;
    height: 42px;
    font-size: 17px;
    margin-bottom: 10px;
}

.cw-compact .cw-heading {
    font-size: 16px;
}

.cw-compact .cw-subtitle {
    font-size: 12.5px;
}

.cw-compact .cw-day {
    height: 30px;
    width: 30px;
    font-size: 12px;
}

.cw-compact .cw-back-to-calendar {
    display: block;
    margin-bottom: 14px;
}

.cw-compact .cw-slots-list {
    max-height: 240px;
}

.cw-compact .cw-duration-pill {
    margin-bottom: 14px;
}

.cw-selected-property {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f5f0f9;
    color: #5f2580;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 14px;
    line-height: 1.4;
}

@media (max-width: 480px) {
    .cw-compact .cw-panel {
        padding: 16px 14px 18px;
    }

    .cw-compact .cw-steps {
        font-size: 9.5px;
        gap: 4px;
    }
}
