/**
 * Modals & Forms Component
 * Diálogos y formularios del sistema
 */

/* === MODAL OVERLAY === */
.zfx-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.55);
    z-index: 2000;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    align-items: flex-start;
    justify-content: center;
    padding: var(--zfx-spacing-xl) var(--zfx-spacing-md);
    overflow-y: auto;
    animation: zfx-fade-in 0.2s ease;
    /* Override WordPress block-theme is-layout-constrained rules which
       inject max-width and auto margins onto all direct children of
       constrained layout blocks — this breaks full-viewport fixed overlays. */
    max-width: none !important;
    width: 100vw !important;
    margin: 0 !important;
    left: 0 !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
}

.zfx-modal-overlay.active {
    display: flex;
}

@keyframes zfx-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* === MODAL DIALOG === */
.zfx-modal {
    background-color: var(--zfx-bg-white);
    border-radius: var(--zfx-border-radius-lg);
    box-shadow: var(--zfx-shadow-xl);
    width: 100%;
    max-width: 600px;
    margin: auto;
    animation: zfx-slide-up 0.25s ease;
    position: relative;
}

.zfx-modal-lg {
    max-width: 760px;
}

@keyframes zfx-slide-up {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* === MODAL PARTS === */
.zfx-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--zfx-spacing-lg) var(--zfx-spacing-xl);
    border-bottom: 1px solid var(--zfx-border-color);
}

.zfx-modal-title {
    font-size: var(--zfx-font-size-xl);
    font-weight: var(--zfx-font-weight-semibold);
    color: var(--zfx-text-primary);
    margin: 0;
}

.zfx-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--zfx-text-muted);
    cursor: pointer;
    padding: var(--zfx-spacing-xs);
    border-radius: var(--zfx-border-radius-sm);
    transition: var(--zfx-transition-fast);
    display: flex;
    align-items: center;
    line-height: 1;
}

.zfx-modal-close:hover {
    background-color: var(--zfx-bg-hover);
    color: var(--zfx-text-primary);
}

.zfx-modal-body {
    padding: var(--zfx-spacing-xl);
    max-height: 65vh;
    overflow-y: auto;
}

.zfx-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--zfx-spacing-md);
    padding: var(--zfx-spacing-lg) var(--zfx-spacing-xl);
    border-top: 1px solid var(--zfx-border-color);
    background-color: var(--zfx-bg-main);
    border-radius: 0 0 var(--zfx-border-radius-lg) var(--zfx-border-radius-lg);
}

/* === FORM === */
.zfx-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--zfx-spacing-md) var(--zfx-spacing-lg);
    margin-bottom: var(--zfx-spacing-md);
}

.zfx-form-row.single {
    grid-template-columns: 1fr;
}

.zfx-form-group {
    display: flex;
    flex-direction: column;
    gap: var(--zfx-spacing-xs);
    margin-bottom: var(--zfx-spacing-md);
}

.zfx-form-group:last-child {
    margin-bottom: 0;
}

.zfx-form-label {
    font-size: var(--zfx-font-size-sm);
    font-weight: var(--zfx-font-weight-medium);
    color: var(--zfx-text-primary);
}

.zfx-form-label .required {
    color: var(--zfx-danger);
    margin-left: 2px;
}

.zfx-form-control {
    width: 100%;
    padding: 0.625rem var(--zfx-spacing-md);
    border: 1px solid var(--zfx-border-color);
    border-radius: var(--zfx-border-radius);
    font-size: var(--zfx-font-size-base);
    font-family: var(--zfx-font-family);
    color: var(--zfx-text-primary);
    background-color: var(--zfx-bg-white);
    transition: var(--zfx-transition-fast);
    line-height: 1.5;
}

.zfx-form-control:focus {
    outline: none;
    border-color: var(--zfx-turquoise);
    box-shadow: 0 0 0 3px rgba(91, 181, 163, 0.15);
}

.zfx-form-control.error {
    border-color: var(--zfx-danger);
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
}

.zfx-form-control:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: var(--zfx-bg-main);
}

textarea.zfx-form-control {
    resize: vertical;
    min-height: 80px;
}

select.zfx-form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237F8C8D' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--zfx-spacing-md) center;
    padding-right: 2.5rem;
}

.zfx-form-error {
    font-size: var(--zfx-font-size-xs);
    color: var(--zfx-danger);
    margin-top: 2px;
    display: none;
}

.zfx-form-error.visible {
    display: block;
}

.zfx-form-hint {
    font-size: var(--zfx-font-size-xs);
    color: var(--zfx-text-muted);
    margin-top: 2px;
}

/* === FORM SECTION DIVIDER === */
.zfx-form-section {
    margin-bottom: var(--zfx-spacing-xl);
}

.zfx-form-section-title {
    font-size: var(--zfx-font-size-sm);
    font-weight: var(--zfx-font-weight-semibold);
    color: var(--zfx-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: var(--zfx-spacing-md);
    padding-bottom: var(--zfx-spacing-sm);
    border-bottom: 1px solid var(--zfx-border-color);
}

/* === ALERT (mensajes dentro del modal) === */
.zfx-alert {
    padding: var(--zfx-spacing-md) var(--zfx-spacing-lg);
    border-radius: var(--zfx-border-radius);
    margin-bottom: var(--zfx-spacing-lg);
    font-size: var(--zfx-font-size-sm);
    display: none;
}

.zfx-alert.visible { display: block; }

.zfx-alert-error {
    background-color: #fdf2f2;
    color: var(--zfx-danger);
    border: 1px solid #fad7d7;
}

.zfx-alert-success {
    background-color: #f0faf5;
    color: var(--zfx-success);
    border: 1px solid #c3e6d0;
}

/* === SCHEDULE EDITOR === */
.zfx-schedule-editor {
    border: 1px solid var(--zfx-border-color);
    border-radius: var(--zfx-border-radius);
    overflow: hidden;
}

.zfx-schedule-row {
    display: grid;
    grid-template-columns: 130px 44px 1fr 1fr;
    align-items: center;
    gap: var(--zfx-spacing-md);
    padding: var(--zfx-spacing-sm) var(--zfx-spacing-md);
    border-bottom: 1px solid var(--zfx-border-color);
    transition: background-color var(--zfx-transition-fast);
}

.zfx-schedule-row:last-child {
    border-bottom: none;
}

.zfx-schedule-row.disabled {
    background-color: var(--zfx-bg-main);
}

.zfx-schedule-row.disabled .zfx-schedule-time {
    opacity: 0.35;
    pointer-events: none;
}

.zfx-schedule-day {
    font-weight: var(--zfx-font-weight-medium);
    font-size: var(--zfx-font-size-sm);
    color: var(--zfx-text-primary);
}

.zfx-schedule-toggle {
    width: 36px;
    height: 20px;
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.zfx-schedule-toggle input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.zfx-schedule-toggle-track {
    width: 36px;
    height: 20px;
    background-color: var(--zfx-border-color);
    border-radius: 10px;
    transition: var(--zfx-transition-fast);
    position: relative;
}

.zfx-schedule-toggle-track::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background-color: white;
    top: 3px;
    left: 3px;
    transition: var(--zfx-transition-fast);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.zfx-schedule-toggle input:checked + .zfx-schedule-toggle-track {
    background-color: var(--zfx-turquoise);
}

.zfx-schedule-toggle input:checked + .zfx-schedule-toggle-track::after {
    transform: translateX(16px);
}

.zfx-schedule-time {
    display: flex;
    align-items: center;
    gap: var(--zfx-spacing-xs);
    font-size: var(--zfx-font-size-sm);
}

.zfx-schedule-time input[type="time"] {
    padding: 4px var(--zfx-spacing-sm);
    border: 1px solid var(--zfx-border-color);
    border-radius: var(--zfx-border-radius-sm);
    font-size: var(--zfx-font-size-sm);
    color: var(--zfx-text-primary);
    background-color: var(--zfx-bg-white);
    width: 90px;
}

.zfx-schedule-time input[type="time"]:focus {
    outline: none;
    border-color: var(--zfx-turquoise);
}

.zfx-schedule-time-sep {
    color: var(--zfx-text-muted);
    font-size: var(--zfx-font-size-xs);
}

/* === TOAST NOTIFICATION === */
.zfx-toast {
    position: fixed;
    bottom: var(--zfx-spacing-xl);
    right: var(--zfx-spacing-xl);
    padding: var(--zfx-spacing-md) var(--zfx-spacing-lg);
    border-radius: var(--zfx-border-radius);
    color: #fff;
    font-size: var(--zfx-font-size-sm);
    font-weight: var(--zfx-font-weight-medium);
    box-shadow: var(--zfx-shadow-lg);
    z-index: 9999;
    transform: translateY(20px);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    max-width: 340px;
}

.zfx-toast.show {
    transform: translateY(0);
    opacity: 1;
}

.zfx-toast.success { background-color: var(--zfx-success); }
.zfx-toast.error   { background-color: var(--zfx-danger); }
.zfx-toast.info    { background-color: var(--zfx-info); }

/* === CONFIRM DIALOG === */
.zfx-confirm-modal .zfx-modal {
    max-width: 420px;
}

.zfx-confirm-icon {
    font-size: 3rem;
    text-align: center;
    margin-bottom: var(--zfx-spacing-md);
}

.zfx-confirm-icon.danger { color: var(--zfx-danger); }

.zfx-confirm-text {
    text-align: center;
    color: var(--zfx-text-secondary);
    font-size: var(--zfx-font-size-base);
}

/* === RESPONSIVE === */
@media (max-width: 767px) {
    .zfx-modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .zfx-modal {
        border-radius: var(--zfx-border-radius-lg) var(--zfx-border-radius-lg) 0 0;
        max-width: 100%;
        margin: 0;
    }

    .zfx-modal-body {
        max-height: 70vh;
    }

    .zfx-form-row {
        grid-template-columns: 1fr;
    }

    .zfx-schedule-row {
        grid-template-columns: 100px 44px 1fr;
        flex-wrap: wrap;
    }

    .zfx-toast {
        bottom: var(--zfx-spacing-md);
        right: var(--zfx-spacing-md);
        left: var(--zfx-spacing-md);
        max-width: none;
    }
}

/* ---------------------------------------------------------------
 * Feature 2 — Notes required label + Photo Upload Zone
 * ------------------------------------------------------------- */

.zfx-label-required {
    font-weight: 600;
}

.zfx-label-hint {
    font-weight: 400;
    font-size: 0.78rem;
    color: var(--zfx-text-muted, #888);
    margin-left: 0.25rem;
}

.zfx-photo-upload-zone {
    position: relative;
    border: 2px dashed var(--zfx-border, #ddd);
    border-radius: var(--zfx-radius-md, 8px);
    min-height: 120px;
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.2s;
}

.zfx-photo-upload-zone:hover {
    border-color: var(--zfx-primary, #7c3aed);
}

.zfx-photo-file-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.zfx-photo-upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.5rem;
    color: var(--zfx-text-muted, #888);
    font-size: 0.875rem;
    min-height: 120px;
}

.zfx-photo-upload-placeholder .dashicons {
    font-size: 2rem;
    width: 2rem;
    height: 2rem;
}

.zfx-photo-preview-wrapper {
    position: relative;
    min-height: 120px;
}

.zfx-photo-preview-img {
    display: block;
    max-height: 200px;
    max-width: 100%;
    object-fit: contain;
    margin: 0 auto;
    padding: 0.5rem;
}

.zfx-photo-remove-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(0,0,0,0.55);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 1.75rem;
    height: 1.75rem;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.zfx-photo-remove-btn:hover {
    background: rgba(220,38,38,0.85);
}

.zfx-ref-photo-thumb {
    max-width: 180px;
    max-height: 140px;
    object-fit: cover;
    border-radius: var(--zfx-radius-sm, 4px);
    border: 1px solid var(--zfx-border, #ddd);
    cursor: pointer;
}

/* ---------------------------------------------------------------
 * Feature 3 — Multi-day calendar views (3-Days & Week)
 * ------------------------------------------------------------- */

/* View toggle buttons */
.zfx-view-btn {
    padding: 0.35rem 0.75rem;
    font-size: 0.82rem;
    background: transparent;
    border: 1px solid var(--zfx-border, #ddd);
    border-radius: var(--zfx-radius-sm, 4px);
    cursor: pointer;
    color: var(--zfx-text-muted, #666);
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    line-height: 1.4;
}
.zfx-view-btn:hover {
    background: var(--zfx-bg-hover, #f5f5f5);
    color: var(--zfx-text, #333);
}
.zfx-view-btn.active {
    background: var(--zfx-primary, #7c3aed);
    border-color: var(--zfx-primary, #7c3aed);
    color: #fff;
}

/* Timeline nav bar */
.zfx-timeline-nav {
    display: flex;
    align-items: center;
    gap: var(--zfx-spacing-sm, 0.5rem);
    padding: var(--zfx-spacing-sm, 0.5rem) var(--zfx-spacing-md, 1rem);
    border-bottom: 1px solid var(--zfx-border, #eee);
}

.zfx-timeline-title {
    flex: 1;
    text-align: center;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--zfx-text, #333);
}

/* Multi-day wrapper */
.zfx-mday-wrapper {
    display: flex;
    overflow-x: auto;
    min-height: 720px;
}

/* Time column */
.zfx-mday-time-col {
    flex: 0 0 52px;
    padding-top: 40px; /* matches col-header height */
    border-right: 1px solid var(--zfx-border, #eee);
    background: var(--zfx-bg-subtle, #fafafa);
}

.zfx-mday-hour-label {
    height: 60px;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 0 8px 0 0;
    font-size: 0.72rem;
    color: var(--zfx-text-muted, #999);
    border-top: 1px solid var(--zfx-border, #eee);
    box-sizing: border-box;
}

/* Date columns container */
.zfx-mday-cols {
    display: flex;
    flex: 1;
    min-width: 0;
}

/* Individual date column */
.zfx-mday-col {
    flex: 1;
    min-width: 120px;
    border-right: 1px solid var(--zfx-border, #eee);
}
.zfx-mday-col:last-child {
    border-right: none;
}
.zfx-mday-col-today > .zfx-mday-col-header {
    background: var(--zfx-primary-light, #ede9fe);
    color: var(--zfx-primary, #7c3aed);
    font-weight: 700;
}

.zfx-mday-col-header {
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    background: var(--zfx-bg-subtle, #fafafa);
    border-bottom: 1px solid var(--zfx-border, #eee);
    position: sticky;
    top: 0;
    z-index: 2;
}

/* Column body */
.zfx-mday-col-body {
    position: relative;
}

/* Hour grid lines */
.zfx-mday-hour-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 60px;
    border-top: 1px solid var(--zfx-border, #eee);
    box-sizing: border-box;
    pointer-events: none;
}

/* Appointment blocks */
.zfx-mday-apt {
    position: absolute;
    left: 2px;
    right: 2px;
    border-radius: 3px;
    padding: 2px 4px;
    font-size: 0.72rem;
    line-height: 1.3;
    overflow: hidden;
    cursor: pointer;
    border-left: 3px solid transparent;
    background: var(--zfx-primary-light, #ede9fe);
    border-left-color: var(--zfx-primary, #7c3aed);
    transition: filter 0.15s;
    z-index: 1;
}
.zfx-mday-apt:hover {
    filter: brightness(0.94);
    z-index: 2;
}
.zfx-mday-apt.zfx-timeline-apt-confirmed {
    background: #d1fae5;
    border-left-color: #059669;
}
.zfx-mday-apt.zfx-timeline-apt-completed {
    background: #f3f4f6;
    border-left-color: #6b7280;
    opacity: 0.8;
}
.zfx-mday-apt.zfx-timeline-apt-cancelled {
    background: #fee2e2;
    border-left-color: #dc2626;
    text-decoration: line-through;
    opacity: 0.7;
}
.zfx-mday-apt.zfx-timeline-apt-no_show {
    background: #fef3c7;
    border-left-color: #d97706;
}

.zfx-mday-apt-name {
    display: block;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.zfx-mday-apt-time {
    display: block;
    font-size: 0.68rem;
    color: var(--zfx-text-muted, #666);
}
.zfx-mday-apt-svc {
    display: block;
    font-size: 0.68rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--zfx-text-muted, #666);
}

/* Week view: narrower font */
#zfxWeekView .zfx-mday-col {
    min-width: 90px;
}
#zfxWeekView .zfx-mday-apt {
    font-size: 0.66rem;
}

@media (max-width: 768px) {
    .zfx-mday-col {
        min-width: 80px;
    }
}
