:root {
    --apple-radius: 12px;
    --apple-radius-lg: 18px;
    --sidebar-width: 260px;
    --transition-speed: 0.3s;
    
    /* Colores de Acento Apple dinámicos */
    --apple-accent: #0071e3;
    --apple-accent-rgb: 0, 113, 227;
    --apple-accent-hover: #005bb5;
    --input-bg: #FCFCFC;
}

body {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: #f5f5f7;
    overflow-x: hidden;
    transition: background-color var(--transition-speed) ease;
}

[data-bs-theme="dark"] body {
    background-color: #000000;
}

/* --- Estilo Apple Glassmorphism --- */
.glass-card {
    background: var(--bs-body-bg);
    border: 1px solid var(--ios-light-gray);
    border-radius: var(--apple-radius);
    overflow: hidden;
    transition: background var(--transition-speed), border var(--transition-speed);
}

[data-bs-theme="dark"] .glass-card {
    border-color: rgba(255, 255, 255, 0.08);
}

/* --- Variables del Sistema Apple --- */
:root {
    --apple-radius: 12px;
    --apple-radius-lg: 18px;
    --sidebar-width: 260px;
    --transition-speed: 0.3s;
    --apple-accent: #0071e3;
    --apple-accent-rgb: 0, 113, 227;
    --apple-accent-hover: #005bb5;
}

body {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: #f5f5f7;
    transition: background-color var(--transition-speed) ease;
}

/* --- Botones Apple (Sistema Completo) --- */
.btn {
    font-weight: 500;
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 0.82rem;
    transition: all 0.2s ease;
    border: none !important;
}
.btn-sm { padding: 3px 10px; font-size: 0.78rem; border-radius: 6px; }
.btn-block { display: flex; width: 100%; justify-content: center; }

.btn:hover { transform: translateY(-1px); filter: brightness(1.1); box-shadow: 0 4px 8px rgba(0,0,0,0.1); }

.btn-primary { background-color: var(--apple-accent) !important; color: #ffffff !important; }
.btn-secondary { background-color: #8e8e93 !important; color: #ffffff !important; }
.btn-success { background-color: #34c759 !important; color: #ffffff !important; }
.btn-danger { background-color: #ff3b30 !important; color: #ffffff !important; }
.btn-info { background-color: #007aff !important; color: #ffffff !important; }
.btn-warning { background-color: #ff9500 !important; color: #ffffff !important; }
.btn-dark { background-color: #1c1c1e !important; color: #ffffff !important; }
.btn-gray { background-color: #e5e5ea !important; color: #3a3a3c !important; }
.btn-light { background-color: #ffffff !important; color: #000000 !important; border: 1px solid rgba(0,0,0,0.1) !important; }

//* --- Tablas Apple --- */
.table-container { 
    border-radius: var(--apple-radius, 16px); 
    overflow: hidden; 
    background-color: var(--bs-body-bg, #fff); /* Asegura fondo para el redondeado */
    border: 1px solid rgba(0,0,0,0.05); /* Opcional: un borde sutil muy Apple */
}

.table-admin th {
    color: var(--ios-gray);
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 600;
    border-bottom: 1px solid var(--ios-light-gray) !important;
}
.table-admin td {
    vertical-align: middle;
    border-bottom: 1px solid var(--ios-light-gray) !important;
}
.badge-pill {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
}

/* El secreto: Desplazamos el padding aquí y activamos el overflow real */
.table-responsive {
    width: 100% !important;
    overflow-x: auto !important;
    display: block !important;
    padding: 12px; /* El padding se aplica dentro del área de scroll */
    -webkit-overflow-scrolling: touch;
}

/* Sticky column (Acciones) — siempre visible al hacer scroll horizontal */
.table th.sticky-col,
.table td.sticky-col {
    position: sticky;
    right: 0;
    z-index: 2;
    background-color: var(--bs-body-bg, #fff) !important;
}
.table thead th.sticky-col {
    z-index: 3;
    opacity: 1;
}
.table-hover > tbody > tr:hover > td.sticky-col,
.table-hover > tbody > tr:hover > th.sticky-col {
    background-color: var(--bs-body-bg, #fff) !important;
}

/* Quitar padding del contenedor scroll para que la columna sticky quede pegada al borde */
.table-responsive:has(.sticky-col) {
    padding: 0;
}

.table { 
    margin-bottom: 0; 
    vertical-align: middle; 
    width: 100%;
}

/* Evita que las columnas se aplasten en móviles, forzando un ancho mínimo para que se active el scroll */
.table th, .table td {
    white-space: nowrap !important; 
}

.table th { 
    font-weight: 600; 
    font-size: 0.75rem; 
    text-transform: uppercase; 
    padding: 10px 12px; 
    opacity: 0.6; 
}

.table td { 
    padding: 10px 12px; 
    border-bottom: 1px solid rgba(0,0,0,0.04); 
}

.table-sm td, .table-sm th { 
    padding: 8px 12px !important; 
}

.table-borderless td, .table-borderless th { 
    border: none !important; 
}

/* --- Layout Base (Sidebar, Topbar, Main) --- */
.sidebar { width: var(--sidebar-width); height: 100vh; position: fixed; background: rgba(245, 245, 247, 0.5); backdrop-filter: blur(20px); border-right: 1px solid rgba(0, 0, 0, 0.05); }
.topbar { margin-left: var(--sidebar-width); height: 70px; background: rgba(255, 255, 255, 0.6); backdrop-filter: blur(20px); position: sticky; top: 0; z-index: 990; }
.main-content { margin-left: var(--sidebar-width); padding: 20px; }

/* --- Editor Apple (Wysiwyg) --- */
.apple-editor-container { border: 1px solid rgba(0, 0, 0, 0.08); background-color: var(--input-bg); border-radius: 12px; overflow: hidden; }
.apple-editor-toolbar { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; background: rgba(0, 0, 0, 0.03); border-bottom: 1px solid rgba(0, 0, 0, 0.05); }
.apple-editor-body { min-height: 160px; padding: 14px; outline: none; }

/* --- Componentes de Formulario --- */
.apple-form-control { width: 100%; padding: 10px 14px; border-radius: 10px; border: 1px solid rgba(0, 0, 0, 0.08); background-color: var(--input-bg); }
.apple-form-control:focus { background-color: var(--bs-body-bg); border-color: var(--apple-accent); box-shadow: 0 0 0 3px rgba(var(--apple-accent-rgb), 0.18); }

/* --- Dark Mode Support (Base) --- */
[data-bs-theme="dark"] body { background-color: #000000; }
[data-bs-theme="dark"] .sidebar { background: rgba(28, 28, 30, 0.6); }
[data-bs-theme="dark"] .topbar { background: rgba(0, 0, 0, 0.6); }
[data-bs-theme="dark"] .apple-editor-container { background-color: #1c1c1e; }
[data-bs-theme="dark"] .btn-light { background-color: #2c2c2e !important; color: #ffffff !important; }
[data-bs-theme="dark"] .btn-gray { background-color: #3a3a3c !important; color: #ffffff !important; }

.text-accent {
    color: var(--apple-accent) !important;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    background: rgba(245, 245, 247, 0.5);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid rgba(0, 0, 0, 0.05);
    transition: transform var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.15);
    border-radius: 4px;
}

[data-bs-theme="dark"] .sidebar {
    background: rgba(28, 28, 30, 0.6);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar .nav-link {
    color: var(--bs-body-color);
    opacity: 0.8;
    border-radius: 10px;
    margin: 2px 14px;
    padding: 10px 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s ease;
}

.sidebar .nav-link:hover, .sidebar .nav-link[aria-expanded="true"] {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.04);
}

[data-bs-theme="dark"] .sidebar .nav-link:hover, 
[data-bs-theme="dark"] .sidebar .nav-link[aria-expanded="true"] {
    background-color: rgba(255, 255, 255, 0.05);
}

.sidebar .nav-link.active {
    color: #ffffff !important;
    background-color: var(--apple-accent) !important;
    opacity: 1;
}

.submenu .nav-link {
    padding-left: 42px;
    font-size: 0.9rem;
    opacity: 0.7;
}

/* --- Topbar --- */
.topbar {
    margin-left: var(--sidebar-width);
    height: 70px;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 990;
    transition: margin-left var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1), background var(--transition-speed);
}

[data-bs-theme="dark"] .topbar {
    background: rgba(0, 0, 0, 0.6);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* --- Main Content --- */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 20px;
    min-height: calc(100vh - 70px);
    transition: margin-left var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Lógica de Colapso del Sidebar --- */
body.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
}
body.sidebar-collapsed .topbar,
body.sidebar-collapsed .main-content {
    margin-left: 0 !important;
}

/* --- Tablas Modernas --- */
.col-id { width: 50px; text-align: center; }
.table-container {
    border-radius: var(--apple-radius);
    overflow: hidden;
}

.table {
    margin-bottom: 0;
    vertical-align: middle;
}

.table th {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.6;
    padding: 10px 12px;
    background-color: rgba(0,0,0,0.01);
}

.table td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(0,0,0,0.04);
}

[data-bs-theme="dark"] .table td {
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

/* --- Modificadores de Tabla --- */
.table-sm td, .table-sm th {
    padding: 8px 12px !important;
}

.table-borderless td, .table-borderless th {
    border: none !important;
}

/* Mejora visual para tablas sin bordes */
.table-borderless tbody tr:hover {
    background-color: rgba(0,0,0,0.02);
    border-radius: var(--apple-radius);
}

[data-bs-theme="dark"] .table-borderless tbody tr:hover {
    background-color: rgba(255,255,255,0.03);
}

/* --- Dropdowns Apple --- */
.dropdown-menu {
    border-radius: 16px;
    border: 1px solid rgba(0,0,0,0.06);
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    padding: 8px;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

[data-bs-theme="dark"] .dropdown-menu {
    background: rgba(28, 28, 30, 0.94);
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.dropdown-item {
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 0.95rem;
}

/* --- Selectores de Color de Acento --- */
.accent-picker {
    display: flex;
    gap: 8px;
    padding: 6px 12px;
}

.accent-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s, border 0.2s;
    border: 2px solid transparent;
}

.accent-dot:hover {
    transform: scale(1.2);
}

.accent-dot.active {
    border-color: var(--bs-body-color);
}

/* Botones de Iconos */
.btn-icon {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    background: rgba(0, 0, 0, 0.04);
    color: var(--bs-body-color);
    transition: background 0.2s, color 0.2s;
    font-size: 0.85rem;
}

.btn-icon:hover {
    background-color: rgba(0, 0, 0, 0.1);
}
[data-bs-theme="dark"] .btn-icon {
    background: rgba(255, 255, 255, 0.06);
}
[data-bs-theme="dark"] .btn-icon:hover {
    background-color: rgba(255, 255, 255, 0.12);
}

/* --- CONTROLES DE FORMULARIO ESTILO APPLE --- */
.apple-form-group {
    margin-bottom: 0.85rem;
}

.apple-form-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    color: #8e8e93;
    margin-bottom: 4px;
    text-transform: none;
    letter-spacing: -0.01em;
}

[data-bs-theme="dark"] .apple-form-label {
    color: #aeaea3;
}

.apple-form-control,
textarea.apple-form-control,
select.apple-form-control,
.ios-input,
.form-control {
    width: 100%;
    padding: 7px 12px;
    font-size: 0.82rem;
    font-weight: 400;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background-color: var(--input-bg);
    color: var(--bs-body-color);
    transition: all 0.2s ease-in-out;
    outline: none;
    box-shadow: none;
}

select.apple-form-control,
select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238e8e93' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

[data-bs-theme="dark"] .apple-form-control,
[data-bs-theme="dark"] textarea.apple-form-control,
[data-bs-theme="dark"] select.apple-form-control,
[data-bs-theme="dark"] .ios-input,
[data-bs-theme="dark"] .form-control {
    background-color: #1c1c1e;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.apple-form-control:focus,
textarea.apple-form-control:focus,
select.apple-form-control:focus,
.ios-input:focus,
.form-control:focus {
    background-color: var(--bs-body-bg);
    border-color: var(--apple-accent);
    box-shadow: 0 0 0 3px rgba(var(--apple-accent-rgb), 0.18);
}

/* Toggle Switches Estilo iOS */
.apple-switch-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--input-bg);
    border-radius: 10px;
    transition: background var(--transition-speed);
}

.apple-switch-wrapper > div:first-child {
    flex: 1;
    min-width: 0;
}

[data-bs-theme="dark"] .apple-switch-wrapper {
    background: #1c1c1e;
}

.apple-switch {
    width: 51px;
    height: 31px;
    flex-shrink: 0;
    appearance: none;
    background-color: #e3e3e9;
    border-radius: 16px;
    position: relative;
    outline: none;
    cursor: pointer;
    transition: background-color 0.3s;
}

[data-bs-theme="dark"] .apple-switch {
    background-color: #3a3a3c;
}

.apple-switch:checked {
    background-color: var(--apple-accent) !important;
}

.apple-switch::before {
    content: '';
    position: absolute;
    width: 27px;
    height: 27px;
    border-radius: 50%;
    background-color: #ffffff;
    top: 2px;
    left: 2px;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 3px 8px rgba(0,0,0,0.12);
}

.apple-switch:checked::before {
    transform: translateX(20px);
}

/* Radio Buttons Estilo Apple */
.apple-radio-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--input-bg);
    padding: 14px;
    border-radius: 10px;
    margin-bottom: 1.25rem;
}

[data-bs-theme="dark"] .apple-radio-group {
    background: #1c1c1e;
}

.apple-radio-item {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.apple-radio {
    width: 20px;
    height: 20px;
    min-width: 20px;
    appearance: none;
    border: 1.5px solid #c7c7cc;
    border-radius: 50%;
    outline: none;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: border-color 0.2s, background-color 0.2s;
    background-color: #ffffff;
}

[data-bs-theme="dark"] .apple-radio {
    background-color: #2c2c2e;
    border-color: #48484a;
}

.apple-radio:checked {
    border-color: var(--apple-accent) !important;
}

.apple-radio::before {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--apple-accent);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.apple-radio:checked::before {
    transform: translate(-50%, -50%) scale(1);
}

/* --- ESTILOS DE COMPONENTE DEL CALENDARIO POPUP --- */
.apple-picker-popup {
    position: absolute;
    width: 320px;
    z-index: 2000 !important;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.12);
    border: 1px solid rgba(0,0,0,0.06);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 16px;
    display: none;
    animation: pickerOpen 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

[data-bs-theme="dark"] .apple-picker-popup {
    background: rgba(28, 28, 30, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}

@keyframes pickerOpen {
    from { transform: translateY(8px) scale(0.97); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.picker-tabs {
    display: flex;
    background: rgba(0, 0, 0, 0.05);
    padding: 2px;
    border-radius: 8px;
    margin-bottom: 12px;
}

[data-bs-theme="dark"] .picker-tabs {
    background: rgba(255, 255, 255, 0.08);
}

.picker-tab-btn {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 6px;
    border-radius: 6px;
    color: var(--bs-body-color);
    opacity: 0.7;
    transition: all 0.2s;
}

.picker-tab-btn.active {
    background: #ffffff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.06);
    opacity: 1;
}

[data-bs-theme="dark"] .picker-tab-btn.active {
    background: #48484a;
}

.cal-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.cal-nav-btn {
    background: transparent;
    border: none;
    color: var(--apple-accent);
    font-size: 0.95rem;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 6px;
    transition: background 0.15s;
}
.cal-nav-btn:hover {
    background-color: rgba(0,0,0,0.05);
}
[data-bs-theme="dark"] .cal-nav-btn:hover {
    background-color: rgba(255,255,255,0.08);
}

.cal-nav-selectors {
    display: flex;
    align-items: center;
    gap: 4px;
}

.picker-month-select,
.picker-year-select {
    border: 1px solid rgba(0, 0, 0, 0.06);
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    font-size: 0.82rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 8px;
    color: var(--bs-body-color);
    outline: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.picker-month-select:hover,
.picker-year-select:hover {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(0, 0, 0, 0.1);
}

[data-bs-theme="dark"] .picker-month-select,
[data-bs-theme="dark"] .picker-year-select {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

[data-bs-theme="dark"] .picker-month-select:hover,
[data-bs-theme="dark"] .picker-year-select:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.15);
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    text-align: center;
}

.cal-weekday {
    font-size: 0.7rem;
    font-weight: 700;
    color: #8e8e93;
    padding-bottom: 4px;
}

.cal-day {
    font-size: 0.82rem;
    font-weight: 500;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.1s;
    color: var(--bs-body-color);
}

.cal-day:hover:not(.empty) {
    background-color: rgba(0, 0, 0, 0.05);
}
[data-bs-theme="dark"] .cal-day:hover:not(.empty) {
    background-color: rgba(255, 255, 255, 0.1);
}

.cal-day.active-day {
    background-color: var(--apple-accent) !important;
    color: #ffffff !important;
    font-weight: 600;
}

.cal-day.range-mid-day {
    background-color: rgba(var(--apple-accent-rgb), 0.15);
    border-radius: 0;
}

.cal-day.range-start-day {
    background-color: var(--apple-accent) !important;
    color: #ffffff !important;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.cal-day.range-end-day {
    background-color: var(--apple-accent) !important;
    color: #ffffff !important;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.cal-day.empty {
    cursor: default;
}

.time-select-panel {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 12px 0;
}

.time-select-box {
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(0, 0, 0, 0.06);
    font-size: 1.1rem;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 8px;
    color: var(--bs-body-color);
    text-align: center;
    outline: none;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.time-select-box:hover {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(0, 0, 0, 0.1);
}

[data-bs-theme="dark"] .time-select-box {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

[data-bs-theme="dark"] .time-select-box:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.15);
}

/* --- ESTILOS COMPONENTE WYSIWYG EDITOR APPLE --- */
.apple-editor-container {
    border: 1px solid rgba(0, 0, 0, 0.08);
    background-color: var(--input-bg);
    border-radius: 12px;
    overflow: hidden;
    transition: border var(--transition-speed), background var(--transition-speed);
    position: relative;
}

[data-bs-theme="dark"] .apple-editor-container {
    background-color: #1c1c1e;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.apple-editor-container.focus {
    border-color: var(--apple-accent);
    box-shadow: 0 0 0 3px rgba(var(--apple-accent-rgb), 0.18);
    background-color: var(--bs-body-bg);
}

.apple-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.03);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    align-items: center;
}

[data-bs-theme="dark"] .apple-editor-toolbar {
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.apple-editor-btn {
    background: transparent;
    border: none;
    color: var(--bs-body-color);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s;
    opacity: 0.75;
}

.apple-editor-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    opacity: 1;
}

[data-bs-theme="dark"] .apple-editor-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

.apple-editor-btn.active {
    background: rgba(var(--apple-accent-rgb), 0.15);
    color: var(--apple-accent);
    opacity: 1;
}

.apple-editor-divider {
    width: 1px;
    height: 18px;
    background: rgba(0, 0, 0, 0.1);
    margin: 0 6px;
}

[data-bs-theme="dark"] .apple-editor-divider {
    background: rgba(255, 255, 255, 0.1);
}

/* Selectores de la barra de herramientas */
.apple-editor-select {
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    font-weight: 500;
    color: var(--bs-body-color);
    outline: none;
    cursor: pointer;
    transition: all 0.2s;
}
[data-bs-theme="dark"] .apple-editor-select {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.1);
}

.apple-editor-body {
    min-height: 160px;
    padding: 14px;
    outline: none;
    overflow-y: auto;
    color: var(--bs-body-color);
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
}

.apple-editor-body p {
    margin-bottom: 0.5rem;
}

/* Imágenes del editor */
.apple-editor-body img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 8px 0;
    display: block;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transition: outline 0.15s, box-shadow 0.15s;
    cursor: pointer;
    user-select: none;
}

.apple-editor-body img:hover {
    outline: 2px solid rgba(var(--apple-accent-rgb), 0.4);
}

.apple-editor-body img.active-editable-img {
    outline: 2px solid var(--apple-accent) !important;
    box-shadow: 0 0 0 4px rgba(var(--apple-accent-rgb), 0.2), 0 8px 24px rgba(0,0,0,0.15) !important;
}

/* Alineaciones de imágenes */
.apple-editor-body img.align-left {
    float: left;
    margin-right: 16px;
    margin-bottom: 8px;
    max-width: 50%;
}

.apple-editor-body img.align-center {
    margin-left: auto !important;
    margin-right: auto !important;
    float: none;
}

.apple-editor-body img.align-right {
    float: right;
    margin-left: 16px;
    margin-bottom: 8px;
    max-width: 50%;
}

/* Estilos de tablas editables en el lienzo */
.apple-editor-body table {
    border-collapse: collapse;
    width: 100%;
    margin: 12px 0;
    cursor: pointer;
}

.apple-editor-body td, 
.apple-editor-body th {
    outline: none;
    position: relative;
    transition: background-color 0.15s;
}

/* Indicador de celda actualmente seleccionada en tablas */
.apple-editor-body td.active-editable-cell,
.apple-editor-body th.active-editable-cell {
    background-color: rgba(var(--apple-accent-rgb), 0.08) !important;
    outline: 1.5px solid var(--apple-accent) !important;
    outline-offset: -1.5px;
}

/* --- CONTROLES DE IMAGEN Y TABLA FLOTANTES --- */
.apple-img-tools-bubble,
.apple-table-tools-bubble {
    position: absolute;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    padding: 4px 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.12);
    z-index: 1060;
    display: none;
    gap: 4px;
    align-items: center;
    animation: pickerOpen 0.15s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

[data-bs-theme="dark"] .apple-img-tools-bubble,
[data-bs-theme="dark"] .apple-table-tools-bubble {
    background: rgba(28, 28, 30, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 25px rgba(0,0,0,0.4);
}

.apple-img-tools-btn,
.apple-table-tools-btn {
    background: transparent;
    border: none;
    color: var(--bs-body-color);
    padding: 4px 8px;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.apple-img-tools-btn:hover,
.apple-table-tools-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}
[data-bs-theme="dark"] .apple-img-tools-btn:hover,
[data-bs-theme="dark"] .apple-table-tools-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

.apple-img-tools-btn.active,
.apple-table-tools-btn.active {
    background: var(--apple-accent);
    color: #ffffff;
}

/* Tirador del resize */
.apple-img-resize-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    background-color: var(--apple-accent);
    border: 2.5px solid #ffffff;
    border-radius: 50%;
    cursor: nwse-resize;
    z-index: 1061;
    display: none;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.apple-editor-html-view {
    width: 100%;
    min-height: 160px;
    padding: 14px;
    border: none;
    outline: none;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85rem;
    display: none;
    background: transparent;
    color: var(--bs-body-color);
    resize: vertical;
}

/* --- ESTILOS DE MODAL MANDATORIOS --- */
.custom-modal-content {
    border: none !important;
    border-radius: var(--apple-radius-lg) !important;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04) !important;
    background-color: #ffffff;
    overflow: hidden;
    transition: background-color var(--transition-speed);
}

[data-bs-theme="dark"] .custom-modal-content {
    background-color: #1c1c1e;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.3) !important;
}

.custom-modal-header {
    border-bottom: none !important;
    padding: 1.75rem 1.75rem 0.5rem 1.75rem !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.custom-modal-header .modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1f2937;
    letter-spacing: -0.025em;
}

[data-bs-theme="dark"] .custom-modal-header .modal-title {
    color: #f3f4f6;
}

.btn-close-custom {
    background: transparent;
    border: none;
    color: #9ca3af;
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    cursor: pointer;
}

.btn-close-custom:hover {
    background-color: #f3f4f6;
    color: #374151;
}
[data-bs-theme="dark"] .btn-close-custom:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.custom-modal-body {
    padding: 1.75rem !important;
    color: #4b5563;
}
[data-bs-theme="dark"] .custom-modal-body {
    color: #d1d5db;
}

.modern-loader {
    display: inline-block;
    width: 2.5rem;
    height: 2.5rem;
    border: 3px solid rgba(0, 0, 0, 0.05);
    border-radius: 50%;
    border-top-color: var(--apple-accent);
    animation: spin-loader 0.8s linear infinite;
}

[data-bs-theme="dark"] .modern-loader {
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--apple-accent);
}

@keyframes spin-loader {
    to { transform: rotate(360deg); }
}

.visual-modern-modal .modal-dialog.modal-fullscreen {
    min-width: 100%;
    max-width: 100%;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
}

.visual-modern-modal .modal-fullscreen .custom-modal-content {
    height: 100%;
    border-radius: 0 !important;
}

.visual-modern-modal .modal-fullscreen .custom-modal-header {
    padding-bottom: 1.75rem !important;
    border-bottom: 1px solid #f3f4f6 !important;
}
[data-bs-theme="dark"] .visual-modern-modal .modal-fullscreen .custom-modal-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}

/* Alertas Toast */
.toast-container-custom {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1090;
}

.table-borderless th:first-child, .table-borderless td:first-child {
    padding-left: 0 !important;
}
.table-borderless th:last-child, .table-borderless td:last-child {
    padding-right: 0 !important;
}

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%) !important;
        -webkit-transform: translateX(-100%) !important;
    }
    body.sidebar-collapsed .sidebar {
        transform: translateX(-100%) !important;
        -webkit-transform: translateX(-100%) !important;
    }
    .sidebar.show,
    body.sidebar-collapsed .sidebar.show {
        transform: translateX(0) !important;
        -webkit-transform: translateX(0) !important;
        box-shadow: 10px 0 30px rgba(0,0,0,0.08);
        width: 280px;
    }
    .topbar, .main-content {
        margin-left: 0 !important;
    }
}

/* Contenedor principal */
.apple-search-select-box {
    position: relative;
    width: 100%;
    margin-bottom: 20px;
}

/* El "trigger" que parece un input */
.apple-search-select-box .btn-select {
    width: 100%;
    padding: 7px 12px;
    font-size: 0.82rem;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background-color: var(--input-bg);
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--bs-body-color);
    overflow: hidden;
}

.apple-search-select-box .btn-select .selected-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

/* Modo oscuro para el trigger */
[data-bs-theme="dark"] .apple-search-select-box .btn-select {
    background-color: #1c1c1e;
    border-color: rgba(255, 255, 255, 0.06);
}

/* El menú desplegable */
.apple-search-select-box .dropdown-menu {
    width: 100%;
    padding: 8px;
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.08);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}



/* Nuevo estilo para que el File Input sea idéntico a tus otros inputs */
.apple-file-upload label {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 7px 12px;
    font-size: 0.82rem;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background-color: var(--input-bg); /* Mismo gris de fondo */
    color: #8e8e93; /* Color gris suave para el placeholder */
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 0;
}

/* Efecto Hover para que sepa que es interactivo */
.apple-file-upload label:hover {
    border-color: var(--apple-accent);
    background-color: #ececf1;
}

[data-bs-theme="dark"] .apple-file-upload label {
    background-color: #1c1c1e;
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: #aeaea3;
}

/* Corrección de Tablas en Modo Oscuro */
[data-bs-theme="dark"] .table thead {
    background-color: #1c1c1e !important; /* Mismo tono de fondo que el sidebar oscuro */
    color: #ffffff !important;           /* Texto blanco */
}

[data-bs-theme="dark"] .table {
    color: #e1e1e1;                      /* Color del texto del cuerpo de la tabla */
}

/* Opcional: Para que las líneas divisorias se vean bien en oscuro */
[data-bs-theme="dark"] .table td, 
[data-bs-theme="dark"] .table th {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
}

/* --- ESTADO DESHABILITADO (DISABLED) ESTILO APPLE --- */
.apple-form-control:disabled,
textarea.apple-form-control:disabled,
select.apple-form-control:disabled,
.ios-input:disabled {
    background-color: #f2f2f7 !important; /* Un gris más oscurito y sutil (Gris Sistema Apple) */
    color: #8e8e93;                        /* Texto atenuado */
    border-color: rgba(0, 0, 0, 0.04);     /* Borde suavizado */
    cursor: not-allowed;                   /* Cursor de no-interactivo */
    opacity: 1;                            /* Evita que iOS le meta una opacidad extra por defecto */
}

/* Ajuste para Modo Oscuro */
[data-bs-theme="dark"] .apple-form-control:disabled,
[data-bs-theme="dark"] textarea.apple-form-control:disabled,
[data-bs-theme="dark"] select.apple-form-control:disabled,
[data-bs-theme="dark"] .ios-input:disabled {
    background-color: #121214 !important; /* Un gris más oscuro y profundo que el #1c1c1e actual */
    color: #636366;                        /* Texto atenuado en modo oscuro */
    border-color: rgba(255, 255, 255, 0.02);
}

/* ============================================================
   bg-accent-subtle - Clase faltante para fondos de acento suaves
   ============================================================ */
.bg-accent-subtle {
    background-color: color-mix(in srgb, var(--apple-accent) 20%, transparent);
}

/* ============================================================
   ios-header - Encabezado unificado para módulos CRM
   ============================================================ */
.ios-header {
    background-color: var(--bs-body-bg);
    border-bottom: 1px solid var(--ios-light-gray, #E5E5EA);
}

/* ============================================================
   CRM - iOS-style Cards, Widgets, Panels - Dark Mode
   ============================================================ */
[data-bs-theme="dark"] .ios-card,
[data-bs-theme="dark"] .ios-widget,
[data-bs-theme="dark"] .ios-panel,
[data-bs-theme="dark"] .ios-table-container,
[data-bs-theme="dark"] .ios-table-panel {
    background-color: #1c1c1e !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
}

[data-bs-theme="dark"] .ios-list-group {
    background-color: #1c1c1e !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
}

[data-bs-theme="dark"] .ios-list-row {
    border-bottom-color: rgba(255, 255, 255, 0.06) !important;
}

[data-bs-theme="dark"] .ios-picker-container {
    background-color: #2c2c2e !important;
}

[data-bs-theme="dark"] .ios-picker-btn.active {
    background-color: #3a3a3c !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3) !important;
}

[data-bs-theme="dark"] .ios-select-agent {
    color: var(--apple-accent) !important;
}

[data-bs-theme="dark"] .ios-table th {
    color: #8e8e93 !important;
    border-bottom-color: rgba(255, 255, 255, 0.08) !important;
}

[data-bs-theme="dark"] .ios-table td {
    color: #e1e1e1 !important;
    border-bottom-color: rgba(255, 255, 255, 0.05) !important;
}

[data-bs-theme="dark"] .ios-table tr:last-child td {
    border-bottom: none !important;
}

[data-bs-theme="dark"] .ios-textarea {
    background-color: #1c1c1e !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    color: #e1e1e1 !important;
}

[data-bs-theme="dark"] .ios-textarea:focus {
    border-color: var(--apple-accent) !important;
}

[data-bs-theme="dark"] .ios-form-group {
    background-color: #1c1c1e !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
}

[data-bs-theme="dark"] .ios-input-row {
    border-bottom-color: rgba(255, 255, 255, 0.05) !important;
}

[data-bs-theme="dark"] .ios-tag-label {
    background-color: #2c2c2e !important;
    color: #e1e1e1 !important;
}

[data-bs-theme="dark"] .kanban-box {
    background-color: #1c1c1e !important;
    border-color: rgba(255, 255, 255, 0.06) !important;
}

[data-bs-theme="dark"] .kanban-box.drag-over {
    background-color: #2c2c2e !important;
    border-color: var(--apple-accent) !important;
}

[data-bs-theme="dark"] .column-count {
    background-color: #2c2c2e !important;
    color: #8e8e93 !important;
}

[data-bs-theme="dark"] .widget-value {
    color: #ffffff !important;
}

[data-bs-theme="dark"] .ios-progress {
    background-color: #2c2c2e !important;
}

[data-bs-theme="dark"] .ios-panel.text-center .ios-avatar {
    background-color: color-mix(in srgb, var(--apple-accent) 60%, #000) !important;
}

[data-bs-theme="dark"] .ios-header {
    background-color: rgba(28, 28, 30, 0.9) !important;
    border-bottom-color: rgba(255, 255, 255, 0.08) !important;
}

/* === Context Menu (posponer recordatorio) === */
.context-menu {
    position: fixed;
    z-index: 9999;
    min-width: 210px;
    padding: 6px;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.12s ease, transform 0.12s ease;
}
[data-bs-theme="dark"] .context-menu {
    background: rgba(28, 28, 30, 0.94);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}
.context-menu.open {
    opacity: 1;
    transform: scale(1);
}
.context-menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: none;
    border-radius: 10px;
    font-size: 0.85rem;
    color: var(--bs-body-color);
    cursor: pointer;
    transition: background 0.1s;
}
.context-menu button:hover {
    background: rgba(0, 0, 0, 0.04);
}
[data-bs-theme="dark"] .context-menu button:hover {
    background: rgba(255, 255, 255, 0.06);
}
.context-menu hr {
    margin: 4px 0;
    border-color: rgba(0, 0, 0, 0.06);
}
[data-bs-theme="dark"] .context-menu hr {
    border-color: rgba(255, 255, 255, 0.06);
}

/* === Fix Safari backdrop-filter repaint glitch con modales === */
.modal-open .sidebar,
.modal-open .topbar {
    will-change: filter;
}
