/* Medaid Calendar — FullCalendar integration styles */

.medaid-calendar-page {
    padding: 0;
}

/* ─── Professional filter bar ─────────────────────────────── */

.medaid-prof-filter-bar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 16px;
}

.prof-filter-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.prof-filter-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.prof-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    background: #fff;
    color: #374151;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}
.prof-filter-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}
.prof-filter-btn.active {
    background: #3788d8;
    color: #fff;
    border-color: #3788d8;
}
.prof-filter-btn.active .prof-color-dot {
    border: 1.5px solid #fff;
}

.prof-filter-edit-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
    color: #374151;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}
.prof-filter-edit-toggle:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}
.prof-filter-edit-toggle.active {
    border-color: #3788d8;
    color: #2563eb;
    background: #eff6ff;
}

.prof-color-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(0,0,0,0.1);
}

.prof-color-pickers {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding-top: 4px;
    border-top: 1px solid #f3f4f6;
}

.prof-color-picker {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-size: 11px;
    color: #6b7280;
}
.prof-color-picker input[type="color"] {
    width: 20px;
    height: 20px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    padding: 0;
    cursor: pointer;
    background: none;
}
.prof-color-picker input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 1px;
}
.prof-color-picker input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 2px;
}
.prof-color-picker-name {
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.prof-color-save-btn {
    margin-left: auto;
    white-space: nowrap;
    font-size: 12px;
    padding: 4px 14px;
    border-radius: 6px;
    align-self: center;
}

.gcal-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #d1d5db;
}
.gcal-dot.connected {
    background: #10b981;
}

.prof-empty-state {
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
}

.prof-visibility-editor {
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-top: 1px solid #f3f4f6;
    border-bottom: 1px solid #f3f4f6;
    padding: 8px 0;
}

.prof-visibility-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.prof-visibility-name {
    font-size: 12px;
    color: #374151;
}

.prof-visibility-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 7px;
    border: 1px solid #d1d5db;
    background: #fff;
    color: #374151;
    cursor: pointer;
    transition: all 0.15s ease;
}
.prof-visibility-toggle:hover {
    background: #f9fafb;
}
.prof-visibility-toggle.is-hidden {
    color: #9ca3af;
    background: #f3f4f6;
}

.prof-visibility-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ─── Status dot on white badge (inside calendar events) ──── */

.medaid-status-dot-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-radius: 50px;
    padding: 2.5px 2.5px 2.3px 2.5px;
    margin-right: 4px;
    line-height: 1;
    vertical-align: middle;
    flex-shrink: 0;
}
.medaid-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.fc .fc-event .fc-event-main {
    display: flex;
    align-items: center;
}

/* Hide FullCalendar native dot — replaced by medaid-status-dot */
.fc .fc-daygrid-dot-event .fc-daygrid-event-dot {
    display: none;
}

/* Dot-events in month view: show professional color as background */
.fc .fc-daygrid-dot-event {
    border-radius: 4px;
    padding: 2px 4px;
    color: #1f2937;
}
.fc .fc-daygrid-dot-event .fc-event-title {
    font-weight: 500;
}

/* ─── Loading overlay ─────────────────────────────────────── */

#medaid-cal-loading {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.7);
    z-index: 10;
    align-items: center;
    justify-content: center;
}
#medaid-cal-loading .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e5e7eb;
    border-top-color: #3788d8;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Calendar container ──────────────────────────────────── */

.medaid-calendar-container {
    position: relative;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
}

/* FullCalendar overrides for Cuba theme */
.fc {
    font-family: inherit;
}
.fc .fc-toolbar-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: #1f2937;
}
.fc .fc-button {
    font-size: 13px;
    padding: 5px 12px;
    border-radius: 6px;
    font-weight: 500;
    text-transform: none;
}
.fc .fc-button-primary {
    background: #fff;
    color: #374151;
    border-color: #d1d5db;
}
.fc .fc-button-primary:hover {
    background: #f3f4f6;
    color: #111827;
    border-color: #9ca3af;
}
.fc .fc-button-primary.fc-button-active,
.fc .fc-button-primary:active {
    background: #3788d8;
    color: #fff;
    border-color: #3788d8;
}
.fc .fc-today-button {
    background: #fff;
    color: #374151;
    border-color: #d1d5db;
}
.fc .fc-today-button:hover {
    background: #f3f4f6;
}
.fc .fc-today-button:disabled {
    opacity: 0.5;
}
.fc .fc-daygrid-day.fc-day-today {
    background: #eff6ff;
}
.fc .fc-timegrid-now-indicator-line {
    border-color: #ef4444;
}
.fc .fc-timegrid-now-indicator-arrow {
    border-color: #ef4444;
}
.fc .fc-event {
    border-radius: 4px;
    border: none;
    padding: 2px 4px;
    font-size: 12px;
    cursor: pointer;
}
.fc .fc-event.fc-event-dragging {
    opacity: 0.85 !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2) !important;
    z-index: 5;
}
.fc .fc-event.fc-event-mirror {
    border: 2px dashed #2563eb;
    background: rgba(59,130,246,0.15);
    opacity: 0.6;
}
.fc .fc-event.fc-event-selected {
    box-shadow: 0 0 0 2px #2563eb;
}
.fc .fc-daygrid-event {
    margin-bottom: 1px;
}
.fc .fc-event:not(.fc-event-mirror) {
    cursor: grab;
}
.fc .fc-event.fc-event-dragging:not(.fc-event-mirror) {
    cursor: grabbing;
}
.fc .fc-event.fc-event-not-allowed,
.fc .fc-event.fc-event-not-allowed .fc-event-main {
    cursor: pointer !important;
}
.fc .fc-h-event .fc-event-main {
    padding: 1px 4px;
}
.fc .fc-col-header-cell {
    padding: 8px 0;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
}
.fc .fc-timegrid-slot-label {
    font-size: 11px;
    color: #9ca3af;
}
.fc .fc-scrollgrid {
    border-color: #e5e7eb;
}
.fc th, .fc td {
    border-color: #e5e7eb;
}

/* ─── Legend ───────────────────────────────────────────────── */

.medaid-calendar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 10px 16px;
    margin-top: 12px;
    font-size: 12px;
    color: #6b7280;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}
.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

/* ─── Appointment modal ───────────────────────────────────── */

.medaid-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1050;
    align-items: center;
    justify-content: center;
}
.medaid-modal-overlay.show {
    display: flex;
}
.medaid-modal-dialog {
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 480px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    overflow: hidden;
}
.medaid-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
}
.medaid-modal-header h5 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #1f2937;
}
.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #9ca3af;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}
.modal-close:hover { color: #374151; }

.medaid-modal-body {
    padding: 16px 20px;
}
.apt-detail-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.apt-detail-row {
    font-size: 13px;
    color: #374151;
}
.apt-detail-row strong {
    color: #1f2937;
}

.medaid-modal-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid #e5e7eb;
    justify-content: flex-end;
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: capitalize;
}
.status-scheduled { background: #dbeafe; color: #1d4ed8; }
.status-confirmed { background: #e0f2fe; color: #0369a1; }
.status-visited { background: #d1fae5; color: #059669; }
.status-cancelled { background: #fee2e2; color: #dc2626; }
.status-no_show { background: #ffedd5; color: #c2410c; }
.status-recurrence { background: #ede9fe; color: #7c3aed; }

/* ─── Recurrence left border on calendar events ──────────── */

.fc .fc-event[style*="border-left: 3px solid #8b5cf6"],
.fc .fc-event[style*="border-left:3px solid #8b5cf6"] {
    border-left-width: 3px !important;
}

/* ─── Google Calendar toggle button ──────────────────────── */

.medaid-gcal-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    margin-bottom: 12px;
    transition: all 0.15s ease;
}
.medaid-gcal-toggle-btn:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}
.gcal-toggle-chevron {
    transition: transform 0.2s ease;
}
.medaid-gcal-toggle-btn.open .gcal-toggle-chevron {
    transform: rotate(180deg);
}

.medaid-gcal-collapsible {
    overflow: hidden;
}

/* ─── Google Calendar panel ───────────────────────────────── */

.medaid-gcal-panel {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}
.gcal-panel-inner {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.gcal-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
}
.gcal-status-connected {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #374151;
}
.gcal-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #d1d5db;
}
.gcal-status-dot.connected {
    background: #10b981;
}
.gcal-settings-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.gcal-settings-row label {
    font-size: 13px;
    color: #6b7280;
    white-space: nowrap;
    margin: 0;
}
.gcal-settings-row select {
    max-width: 260px;
}
.gcal-last-sync {
    font-size: 12px;
    color: #9ca3af;
}
.gcal-error {
    font-size: 12px;
    color: #ef4444;
    background: #fef2f2;
    padding: 6px 10px;
    border-radius: 6px;
}
.gcal-actions {
    display: flex;
    gap: 8px;
}
.gcal-notice, .gcal-notice-info {
    font-size: 13px;
    color: #6b7280;
    margin: 0;
}
.gcal-notice-info {
    color: #374151;
}

/* ─── Wizard calendari collegati (multi-calendario) ───────── */

.gcal-wizard-hint {
    font-size: 12px;
    color: #6b7280;
    margin: 0 0 8px;
}
.gcal-wizard-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 10px;
    max-height: 360px;
    overflow-y: auto;
}
.gcal-wizard-row {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px;
    background: #fff;
}
.gcal-wizard-row-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}
.gcal-wizard-row-head .gcal-checkbox-label {
    margin: 0;
    font-size: 13px;
}
.gcal-wizard-row-head input[type="color"] {
    width: 34px;
    height: 28px;
    padding: 0;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: none;
    cursor: pointer;
    flex: 0 0 auto;
}
.gcal-wizard-row-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.gcal-wizard-row-body .gcal-wz-field {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #6b7280;
    margin: 0;
}
.gcal-wizard-row-body .gcal-wz-prof {
    max-width: 220px;
}
.gcal-wizard-row-body .gcal-checkbox-label {
    font-size: 12px;
    color: #374151;
    margin: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* ─── Admin settings card ─────────────────────────────────── */

.medaid-gcal-admin-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}
.medaid-gcal-admin-card h6 {
    margin: 0 0 12px;
    font-size: 14px;
    font-weight: 600;
}

/* ─── Responsive ──────────────────────────────────────────── */

@media (max-width: 768px) {
    .medaid-prof-filter-bar {
        gap: 4px;
        padding: 8px 10px;
    }
    .prof-filter-btns {
        gap: 4px;
    }
    .prof-filter-top {
        align-items: center;
    }
    .prof-filter-btn {
        font-size: 12px;
        padding: 4px 10px;
    }
    .prof-color-pickers {
        gap: 6px;
    }
    .fc .fc-toolbar {
        flex-direction: column;
        gap: 8px;
    }
    .fc .fc-toolbar-title {
        font-size: 1rem;
    }
    .medaid-calendar-container {
        padding: 8px;
    }
    .gcal-settings-row {
        flex-direction: column;
        align-items: flex-start;
    }
    .medaid-modal-footer {
        flex-direction: column;
    }
    .medaid-modal-footer .btn {
        width: 100%;
        text-align: center;
    }
}
