/* ============================================
   Zoho Search Section
   ============================================ */

.zoho-search-form {
    margin-bottom: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.zoho-form-main {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.zoho-form-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.zoho-form-row-options {
    gap: 10px;
}

.sunlocs-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    transition: opacity 0.2s;
}

.sunlocs-controls.disabled {
    opacity: 0.35;
    pointer-events: none;
}

.radio-inline-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 42px;
}

.filter-group-radio {
    min-width: auto !important;
}

.zoho-form-row .filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 150px;
}

.zoho-form-row .filter-group label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.zoho-form-row .filter-group select,
.zoho-form-row .filter-group input {
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.zoho-form-row .filter-group select:focus,
.zoho-form-row .filter-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.zoho-form-row .filter-group-text {
    flex: 1;
    min-width: 200px;
}

/* Search mode toggle (Text / Image) */
.search-mode-toggle {
    display: flex;
    background: var(--bg-hover);
    border-radius: var(--radius-sm);
    padding: 2px;
    align-self: center;
}

.search-mode-btn {
    padding: 8px 14px;
    border: none;
    background: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: all 0.2s;
    white-space: nowrap;
}

.search-mode-btn.active {
    background: var(--bg-card);
    color: var(--text-primary);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

/* Zoho image search (thumbnail dropzone) */
.zoho-image-search {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex: 1;
    min-width: 200px;
}

.zoho-image-dropzone {
    position: relative;
    width: 120px;
    height: 90px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.zoho-image-dropzone.has-image {
    border-style: solid;
    border-color: var(--primary);
}

.zoho-image-dropzone:hover {
    border-color: var(--primary);
}

.zoho-image-dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.zoho-dropzone-text {
    font-size: 0.78rem;
    color: var(--text-muted);
    pointer-events: none;
    text-align: center;
    padding: 4px;
    line-height: 1.3;
}

.zoho-image-preview {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.zoho-image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

.btn-remove-preview-sm {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
}

.zoho-similarity-control {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    white-space: nowrap;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.zoho-similarity-control input[type="range"] {
    width: 100px;
}

#zohoSunlocsControls {
    display: contents;
}

#zohoSunlocsControls.hidden {
    display: none;
}

.zoho-btn-buscar {
    margin-left: auto;
    padding: 10px 24px;
    font-weight: 500;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* Similitud Slider */

.similitud-slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0.4;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.similitud-slider-container.active {
    opacity: 1;
    pointer-events: auto;
}

.similitud-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.similitud-label-left {
    color: #64748b;
}

.similitud-label-right {
    color: #059669;
}

.similitud-slider {
    width: 200px;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right, #cbd5e1, #059669);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.similitud-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: white;
    border: 2px solid #059669;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.15s ease;
}

.similitud-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.similitud-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: white;
    border: 2px solid #059669;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.similitud-slider:disabled {
    cursor: not-allowed;
}

.similitud-slider:disabled::-webkit-slider-thumb {
    cursor: not-allowed;
    border-color: #94a3b8;
}

.similitud-slider:disabled::-moz-range-thumb {
    cursor: not-allowed;
    border-color: #94a3b8;
}

@media (max-width: 768px) {
    .zoho-form-row .filter-group {
        width: 100%;
    }
}

.admin-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
}

.admin-section h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* Authorize Registration */
.authorize-reg-form {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
.authorize-reg-form .btn-primary {
    white-space: nowrap;
}
.authorized-user-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color, #f0f0f0);
}
.authorized-user-item:last-child {
    border-bottom: none;
}
.authorized-user-email {
    font-weight: 500;
}
.authorized-user-type {
    font-size: 0.8rem;
    color: var(--text-muted, #888);
    background: var(--bg-tertiary, #f5f7fa);
    padding: 2px 8px;
    border-radius: 10px;
}

/* Backup & Restore */
/* Zoho sync panel */
.zoho-sync-tabla {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}
.zoho-sync-tabla th {
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}
.zoho-sync-tabla td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.zoho-sync-icono { font-size: 1.5rem; width: 40px; text-align: center; }
.zoho-sync-nombre { font-weight: 600; color: var(--text-primary); white-space: nowrap; }
.zoho-sync-desc { color: var(--text-secondary); line-height: 1.45; }
.zoho-sync-accion { width: 1%; white-space: nowrap; }
.zoho-sync-accion .zoho-sync-status { white-space: normal; max-width: 260px; }
@media (max-width: 700px) {
    .zoho-sync-tabla thead { display: none; }
    .zoho-sync-tabla td { display: block; border-bottom: none; padding: 4px 10px; }
    .zoho-sync-tabla tr { display: block; border-bottom: 1px solid var(--border); padding: 8px 0; }
    .zoho-sync-icono { width: auto; text-align: left; }
}
.zoho-sync-status {
    margin-top: 10px;
    font-size: 0.82rem;
    min-height: 18px;
}
.zoho-sync-status-loading { color: var(--text-muted); }
.zoho-sync-status-ok { color: #16a34a; }
.zoho-sync-status-error { color: var(--danger, #ef4444); }

/* Diálogo de confirmación de borrados de la sync de Zoho */
.zoho-del-modal { max-width: 560px; width: 92%; }
.zoho-del-body {
    padding: 18px 22px;
    max-height: 55vh;
    overflow-y: auto;
}
.zoho-del-lead { margin: 0 0 14px; font-size: 0.92rem; line-height: 1.45; }
.zoho-del-group { margin-bottom: 14px; }
.zoho-del-group-title {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 6px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.zoho-del-list {
    margin: 0;
    padding-left: 18px;
    font-size: 0.88rem;
    line-height: 1.5;
}
.zoho-del-list li { margin-bottom: 2px; }
.zoho-del-id { color: var(--text-muted); font-size: 0.78rem; }
.zoho-del-question { margin: 8px 0 0; font-weight: 600; }
.zoho-del-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 22px 18px;
    border-top: 1px solid var(--border, #e5e7eb);
}

/* Bloque de gestión de elementos marcados por Zoho */
.zoho-pending-block {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--border, #e5e7eb);
}
.zoho-pending-block h3 { margin: 0 0 6px; font-size: 1rem; }
.zoho-pending-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}
.zoho-pending-results {
    margin-top: 14px;
}
.zoho-pending-group { margin-bottom: 14px; }
.zoho-pending-group-title {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 6px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.zoho-pending-listing {
    margin: 0;
    padding-left: 18px;
    font-size: 0.88rem;
    line-height: 1.6;
}
.zoho-pending-listing li { margin-bottom: 3px; }
.zoho-pending-id { color: var(--text-muted); font-size: 0.78rem; }
.zoho-pending-since { color: var(--text-muted); font-size: 0.78rem; font-style: italic; }
.zoho-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: zoho-spin 0.7s linear infinite;
    vertical-align: middle;
    margin-right: 4px;
}
@keyframes zoho-spin { to { transform: rotate(360deg); } }

.btn-secondary {
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

.admin-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.admin-filters input,
.admin-filters select {
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    min-width: 180px;
}

.admin-filters input:focus,
.admin-filters select:focus {
    outline: none;
    border-color: var(--primary);
}

.users-table-container {
    overflow-x: auto;
}

.users-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.users-table th,
.users-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.users-table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #f8f9fa;
}

.users-table tbody tr:hover {
    background: var(--bg-hover);
}

.users-table .user-current {
    background: #f0f9ff;
}

.user-email-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar-small {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--primary-text);
    flex-shrink: 0;
}

.status-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-active {
    background: #dcfce7;
    color: #16a34a;
}

.status-banned {
    background: #fee2e2;
    color: #dc2626;
}

.status-pending {
    background: #fef2f2;
    color: #b91c1c;
}

.role-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.role-admin {
    background: #fef3c7;
    color: #d97706;
}

/* Super Admin: administrador de plataforma (workspace Sunlocs) */
.role-superadmin {
    background: #ede9fe;
    color: #6d28d9;
    white-space: nowrap;
}

.wm-header-note {
    font-weight: 400;
    font-size: 0.78rem;
    color: var(--text-muted, #64748b);
}

.wm-card-body {
    padding: 12px 14px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
}

.wm-preview-wrap {
    min-width: 180px;
    max-width: 260px;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed var(--border-color, #cbd5e1);
    border-radius: 8px;
    padding: 8px;
    background:
        repeating-conic-gradient(#eceff3 0% 25%, #ffffff 0% 50%) 0 0 / 16px 16px;
}

.wm-preview-wrap img {
    max-width: 240px;
    max-height: 80px;
    object-fit: contain;
}

#wmPreviewEmpty {
    color: var(--text-muted, #64748b);
    font-size: 0.8rem;
    text-align: center;
}

.wm-actions {
    display: flex;
    gap: 8px;
}

.wm-hint {
    flex-basis: 100%;
    margin: 0;
    color: var(--text-muted, #64748b);
    font-size: 0.78rem;
}

.role-user {
    background: #e0e7ff;
    color: #4f46e5;
}

.actions-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.btn-action {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
}

.btn-action:hover {
    transform: translateY(-1px);
}

.btn-make-admin {
    color: #4f46e5;
    border-color: #4f46e5;
}

.btn-make-admin:hover {
    background: #4f46e5;
    color: white;
}

.btn-delete {
    color: var(--error);
    border-color: var(--error);
    border-radius: 999px;
}

.btn-delete:hover {
    background: var(--error-light);
    color: var(--error);
}

.current-user-label {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-style: italic;
}

@media (max-width: 768px) {

    .admin-filters {
        flex-direction: column;
    }

    .admin-filters input,
    .admin-filters select {
        width: 100%;
    }

    .users-table {
        font-size: 0.8rem;
    }

    .users-table th,
    .users-table td {
        padding: 8px 10px;
    }

    .actions-cell {
        flex-direction: column;
    }
}

