/* ============================================================
   TEMA GLOBAL - Terceros y widgets
   Select2, Schedule-X, SweetAlert, timepicker y tooltips.
   ============================================================ */

/* ---------- Select2 ---------- */
html[data-theme="dark"] .select2-container--default .select2-selection--single,
html[data-theme="dark"] .select2-container--default .select2-selection--multiple,
html[data-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__rendered,
html[data-theme="dark"] .select2-container--default .select2-selection--multiple .select2-selection__rendered {
    background-color: var(--input-bg) !important;
    color: var(--text-primary) !important;
    border-color: var(--input-border) !important;
}

html[data-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__placeholder,
html[data-theme="dark"] .select2-container--default .select2-selection--multiple .select2-selection__placeholder {
    color: var(--text-muted) !important;
}

html[data-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__arrow,
html[data-theme="dark"] .select2-container--default .select2-selection--multiple .select2-selection__arrow {
    border-color: transparent !important;
}

html[data-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-color: var(--text-muted) transparent transparent transparent !important;
}

html[data-theme="dark"] .select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b {
    border-color: transparent transparent var(--text-muted) transparent !important;
}

html[data-theme="dark"] .select2-container--default.select2-container--focus .select2-selection--single,
html[data-theme="dark"] .select2-container--default.select2-container--open .select2-selection--single,
html[data-theme="dark"] .select2-container--default.select2-container--focus .select2-selection--multiple,
html[data-theme="dark"] .select2-container--default.select2-container--open .select2-selection--multiple {
    border-color: var(--input-focus) !important;
    box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.16) !important;
}

html[data-theme="dark"] .select2-container--default.select2-container--disabled .select2-selection--single,
html[data-theme="dark"] .select2-container--default.select2-container--disabled .select2-selection--multiple {
    background-color: var(--bg-surface-2) !important;
    color: var(--text-muted) !important;
}

html[data-theme="dark"] .select2-dropdown,
html[data-theme="dark"] .select2-container--default .select2-dropdown,
html[data-theme="dark"] .select2-container--default .select2-dropdown .select2-search--dropdown {
    background-color: var(--bg-elevated) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

html[data-theme="dark"] .select2-container--default .select2-search--dropdown .select2-search__field {
    background-color: var(--input-bg) !important;
    color: var(--text-primary) !important;
    border-color: var(--input-border) !important;
}

html[data-theme="dark"] .select2-container--default .select2-results__option {
    background-color: var(--bg-elevated) !important;
    color: var(--text-secondary) !important;
}

html[data-theme="dark"] .select2-container--default .select2-results__option--highlighted,
html[data-theme="dark"] .select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: var(--accent) !important;
    color: #ffffff !important;
}

html[data-theme="dark"] .select2-container--default .select2-results__option[aria-selected="true"] {
    background-color: var(--bg-surface-2) !important;
    color: var(--text-primary) !important;
}

html[data-theme="dark"] .select2-results__message,
html[data-theme="dark"] .select2-container--default .select2-results__message {
    color: var(--text-muted) !important;
}

html[data-theme="dark"] .select2-selection__choice {
    background-color: var(--bg-surface-2) !important;
    border-color: var(--border-strong) !important;
    color: var(--text-primary) !important;
}

html[data-theme="dark"] .select2-selection__choice__remove {
    color: var(--danger) !important;
}

/* ---------- Schedule-X Calendar ---------- */
html[data-theme="dark"] .calendar,
html[data-theme="dark"] .sx__calendar,
html[data-theme="dark"] .sx__calendar-wrapper,
html[data-theme="dark"] .sx__date-picker-wrapper,
html[data-theme="dark"] .sx__date-picker-popup {
    background-color: var(--bg-surface) !important;
    color: var(--text-primary) !important;
}

html[data-theme="dark"] .sx__calendar-header,
html[data-theme="dark"] .sx__calendar.is-dark .sx__calendar-header,
html[data-theme="dark"] .is-dark .sx__calendar-header,
html[data-theme="dark"] .sx__view-selection,
html[data-theme="dark"] .sx__today-button,
html[data-theme="dark"] .sx__date-input,
html[data-theme="dark"] .sx__month-grid-header,
html[data-theme="dark"] .sx__month-grid-day,
html[data-theme="dark"] .sx__week-grid-header,
html[data-theme="dark"] .sx__time-grid-day {
    background-color: var(--bg-surface) !important;
    color: var(--text-secondary) !important;
    border-color: var(--border-color) !important;
}

html[data-theme="dark"] .sx__month-grid-day__header-day-name,
html[data-theme="dark"] .sx__week-grid__day-name,
html[data-theme="dark"] .sx__time-grid-day__header-day-name {
    color: var(--text-muted) !important;
}

html[data-theme="dark"] .sx__month-grid-day__header-date.sx__is-today,
html[data-theme="dark"] .sx__week-grid__date.sx__is-today {
    background-color: #2f7a00 !important;
    color: #ffffff !important;
}

html[data-theme="dark"] .is-dark,
html[data-theme="dark"] .sx__calendar.is-dark,
html[data-theme="dark"] .sx__calendar-wrapper.is-dark {
    --sx-color-primary: #2f7a00;
    --sx-color-on-primary: #ffffff;
    --sx-color-primary-container: #1c3a22;
    --sx-color-on-primary-container: #d9fbe3;
    --sx-color-secondary: #4ade80;
    --sx-color-on-secondary: #052e16;
    --sx-color-secondary-container: #16351f;
    --sx-color-on-secondary-container: #d9fbe3;
    --sx-color-surface: #10161f;
    --sx-color-surface-dim: #0a0e14;
    --sx-color-surface-bright: #1a2533;
    --sx-color-on-surface: #e8edf5;
    --sx-color-surface-container: #16202c;
    --sx-color-surface-container-low: #111a26;
    --sx-color-surface-container-high: #1e2a3a;
    --sx-color-background: #10161f;
    --sx-color-on-background: #e8edf5;
    --sx-color-outline: #64748b;
    --sx-color-outline-variant: #2a3648;
    --sx-internal-color-text: #e8edf5;
    --sx-internal-color-light-gray: #16202c;
    --sx-internal-color-gray-ripple-background: #1e2a3a;
}

html[data-theme="dark"] .calendar-container,
html[data-theme="dark"] .agenda-side-column,
html[data-theme="dark"] .agenda-hero-column,
html[data-theme="dark"] .agenda-day-column,
html[data-theme="dark"] .agenda-event-card,
html[data-theme="dark"] .timeline-row,
html[data-theme="dark"] .timeline-events-container {
    background-color: var(--bg-surface) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

html[data-theme="dark"] .agenda-day-column.is-empty,
html[data-theme="dark"] .agenda-empty-state {
    background-color: var(--bg-surface-2) !important;
    color: var(--text-muted) !important;
}

html[data-theme="dark"] .agenda-day-header,
html[data-theme="dark"] .agenda-event-title,
html[data-theme="dark"] .resource-label,
html[data-theme="dark"] .time-slot-label {
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

html[data-theme="dark"] .agenda-event-card > div:first-child > div:first-child,
html[data-theme="dark"] .timeline-bar > div > div {
    background-color: var(--bg-surface-2) !important;
    color: var(--text-secondary) !important;
}

html[data-theme="dark"] .agenda-event-card strong,
html[data-theme="dark"] .agenda-event-card span {
    color: var(--text-primary);
}

html[data-theme="dark"] .agenda-event-card > div:last-child {
    border-top-color: var(--border-color) !important;
}

html[data-theme="dark"] .agenda-event-card > div:last-child > div:first-child,
html[data-theme="dark"] .agenda-event-card > div:last-child > div:last-child > div {
    background-color: var(--bg-surface-2) !important;
    color: var(--text-secondary) !important;
    border-color: var(--border-color) !important;
}

html[data-theme="dark"] .agenda-more-btn {
    background-color: var(--bg-surface-2) !important;
    color: var(--text-secondary) !important;
    border-color: var(--border-color) !important;
}

html[data-theme="dark"] .event-modal .modal-content,
html[data-theme="dark"] #eventModal .modal-content,
html[data-theme="dark"] .event-details-container,
html[data-theme="dark"] .detail-box,
html[data-theme="dark"] .detail-card {
    background-color: var(--bg-surface) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

html[data-theme="dark"] .detail-card-icon,
html[data-theme="dark"] .detail-box-icon {
    background-color: var(--bg-surface-2) !important;
}

html[data-theme="dark"] .detail-label {
    color: var(--text-muted) !important;
}

html[data-theme="dark"] .detail-value {
    color: var(--text-primary) !important;
}

html[data-theme="dark"] .now-indicator {
    background-color: var(--danger) !important;
}

/* ---------- SweetAlert ---------- */
html[data-theme="dark"] .swal2-popup,
html[data-theme="dark"] .swal-premium-popup {
    background: var(--bg-elevated) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

html[data-theme="dark"] .swal2-title,
html[data-theme="dark"] .swal-premium-title,
html[data-theme="dark"] .swal2-html-container,
html[data-theme="dark"] .swal-premium-html {
    color: var(--text-primary) !important;
}

html[data-theme="dark"] .swal2-content,
html[data-theme="dark"] .swal2-footer {
    color: var(--text-secondary) !important;
    border-color: var(--border-color) !important;
}

html[data-theme="dark"] .swal2-close,
html[data-theme="dark"] .swal-premium-close {
    color: var(--text-muted) !important;
}

html[data-theme="dark"] .swal2-close:hover {
    color: var(--danger) !important;
}

html[data-theme="dark"] .swal2-styled.swal2-confirm {
    background-color: var(--accent) !important;
    color: #ffffff !important;
}

html[data-theme="dark"] .swal2-styled.swal2-cancel {
    background-color: var(--bg-surface-2) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border-color) !important;
}

html[data-theme="dark"] .swal-event-list-item {
    background-color: var(--bg-surface-2) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

html[data-theme="dark"] .swal-event-list-title,
html[data-theme="dark"] .swal-event-list-aula,
html[data-theme="dark"] .swal-event-list-time {
    color: var(--text-secondary) !important;
}

/* ---------- Timepicker ---------- */
html[data-theme="dark"] .ui-timepicker-wrapper {
    background: var(--bg-elevated) !important;
    border-color: var(--border-color) !important;
    box-shadow: var(--shadow-lg) !important;
}

html[data-theme="dark"] .ui-timepicker-list li {
    background: var(--bg-elevated) !important;
    color: var(--text-secondary) !important;
}

html[data-theme="dark"] .ui-timepicker-list li:hover,
html[data-theme="dark"] .ui-timepicker-list li.ui-timepicker-selected,
html[data-theme="dark"] .ui-timepicker-list li.ui-timepicker-selected:hover {
    background: var(--accent) !important;
    color: #ffffff !important;
}

html[data-theme="dark"] .ui-timepicker-list li.ui-timepicker-disabled,
html[data-theme="dark"] .ui-timepicker-list li.ui-timepicker-disabled:hover {
    background: var(--bg-surface-2) !important;
    color: var(--text-muted) !important;
}

/* ---------- Tippy ---------- */
html[data-theme="dark"] .tippy-box[data-theme~='light-border'] {
    background-color: var(--bg-elevated) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
    box-shadow: var(--shadow-md) !important;
}

html[data-theme="dark"] .tippy-box[data-theme~='light-border'] > .tippy-content {
    color: var(--text-primary) !important;
}

html[data-theme="dark"] .tippy-box[data-theme~='light-border'] > .tippy-arrow::before {
    border-color: var(--border-color) !important;
}
